Hello i have the following code..
#define VB_CHAR signed char
#define VB_UCHAR unsigned char
#if defined(VBISAM_NO_CISAM_CONFLICT)
#include "vbisam_rename.h"
#endif
#include "vbdecimal.h"
vbdecimal doesnt include any other header but fails to see it
Error 1 error C2065: 'VB_CHAR' : undeclared identifier c:\users\parhs\documents\visual studio 2010\projects\testdll4\vbdecimal.h
I have to define VB_CHAR in vbdecimal in order to work..
Any work-around for this?
Well. It could be that vbisam_rename.h '#undefs' VB_CHAR.
Related
This is a silly compilation error, but for the life of me I can't find out what's wrong. I have spent hours on it, but I have made no progress at all. And I certainly don't understand enough about OpenSSL to understand what an X509_NAME is.
I'm compiling a small C file whose function it is to print out an error message if anyone calls one of the 30 or so functions in the file, to indicate that the 30 SSL functions are not supported by the C program. Each function is about 3 lines long (see below). The calling interface is copied from the OpenSSL openssl/X509.h file for win32. (I'm running Windows10 x64, but compiling with VStudio 2017 command line set up for 32bits).
Here is the original interface from the openssl/x509.h include file:
int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);
Since the original x509.h include file says inside that "the definition for X509_NAME on Win32 is located in wincrypt.h," I copied the definition for the X509_NAME macro directly into my source file as shown below.
The code for my simple error message function follows. I just copied the interface definition from the openssl/x509.h file and made it into a function:
#define X509_NAME ((LPCSTR) 7) /* copied from wincrypt.h */
int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) {
print_error (E_NO_SSL_SUPPORT);
return (-1);
}
When I try to compile the code with the VS 2017 command line compiler for 32bits, I get these error messages. Line 236 contains the troublesome code line int X509_NAME_....
cl /c /Od /nologo /MT /I. "-I..\s" ..\s\stubssl.c
stubssl.c
..\s\stubssl.c(236): error C2143: syntax error: missing ')' before '('
..\s\stubssl.c(236): error C2091: function returns function
..\s\stubssl.c(236): error C2059: syntax error: ')'
..\s\stubssl.c(236): error C2143: syntax error: missing ')' before 'constant'
..\s\stubssl.c(236): error C2143: syntax error: missing '{' before 'constant'
..\s\stubssl.c(236): error C2059: syntax error: 'constant'
..\s\stubssl.c(242): error C2059: syntax error: '<parameter-list>'
c:\stubssl\winxp\make.exe: *** [stubssl.obj] Error 2
I get the same kind of error with another function that is a bit simpler (but that also uses the X509_NAME macro). It starts on line 242 (see the error messages above).
X509_NAME *X509_get_subject_name(X509 *a) {
hio_oerror (E_NO_SSL_SUPPORT);
return (NULL);
}
Does anyone have any idea how I might try to resolve this problem? It seems so simple, yet it has been very elusive for me to solve. I can't imagine how I can be missing ')' before '(' in those lines.
EDIT: My include files in stubssl.c:
#define WIN32_LEAN_AND_MEAN
#include "openssl/ssl.h"
#include "openssl/x509.h"
#include "openssl/bio.h"
#include "openssl/pem.h"
In openSSL, X509_NAME is a type, but <wincrypt.h> defines it as a value (((LPCSTR) 7)). Don't define it yourself, but use the openSSL header, don't include <wincrypt.h> and #define WIN32_LEAN_AND_MEAN to avoid it being included through other windows headers.
I'm writing an application in ANSI C (Visual Studio 2010)
my library looks like this:
#include <stdio.h>
#include <stdlib.h>
#ifndef _MYLIB_
#define _MYLIB_
typedef enum {false, true} bool;
// some structures and function prototypes...
#endif
I include this library in every .c file (I've got like 4 .c files - 1 main.c with main() and the rest with functions).
I get an error:
Generating Code...
1> first.cpp
1>c:\users\A1\documents\visual studio 2010\projects\pr1\pr1\mylib.h(7): error C2059: syntax error : 'constant'
1>c:\users\A1\documents\visual studio 2010\projects\pr1\pr1\mylib.h(7): error C2143: syntax error : missing ';' before '}'
1>c:\users\A1\documents\visual studio 2010\projects\pr1\pr1\mylib.h(7): error C2059: syntax error : '}'
1> second.cpp
1>c:\users\A1\documents\visual studio 2010\projects\pr1\pr1\mylib.h(7): error C2059: syntax error : 'constant'
1>c:\users\A1\documents\visual studio 2010\projects\pr1\pr1\mylib.h(7): error C2143: syntax error : missing ';' before '}'
1>c:\users\A1\documents\visual studio 2010\projects\pr1\pr1\mylib.h(7): error C2059: syntax error : '}'
What's more - when I paste all functions and structures into main.c - it works properly...
I have no idea how to fix it...
I strongly believe that you are interfering with the C++ built-in false and true, so you are trying to redefine them in your enum.
Try to replace false and true with FALSE and TRUE and bool with BOOL.
#include <stdio.h>
#include <stdlib.h>
#ifndef _MYLIB_
#define _MYLIB_
typedef enum {FALSE, TRUE} BOOL;
// some structures and function prototypes...
#endif
So I'm creating a simple program, and I usually use the GNU compiler.
However, this time I chose to use Visual C++ for developing in C.
I've set up my project correctly, changing the settings to make it compile in C. The code is very simple:
#include <stdlib.h>
#include <stdio.h>
int main(){
printf("Hey!");
int x = 9;
printf("%d",x);
return 0;
}
If I compiled this using Code::Blocks IDE and the GNU compiler, it would work, but for some reason it doesn't work in Visual C++. I keep getting these errors:
error C2143: syntax error : missing ';' before 'type'
error C2065: 'x' : undeclared identifier
How can I fix this?
VC++ 2010 only implements C89/C90, not the newer C standards that allow variable declarations after other statements inside of a function body. To fix it, move the declaration of x to the beginning of main:
#include <stdlib.h>
#include <stdio.h>
int main() {
int x = 9;
printf("Hey!");
printf("%d",x);
return 0;
}
Change the file extension to .cpp
I'm trying to use SendInput() function. I wrote this code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winuser.h>
#define WIN32_LEAN_AND_MEAN
//...
KEYBDINPUT kbi;
kbi.wVk = 0x31;
kbi.wScan = 0;
kbi.dwFlags = 0;
kbi.time = 0;
INPUT input;
input.type = INPUT_KEYBOARD;
input.ki = kbi;
SendInput(1, &input, sizeof input);
Compiling:
gcc -Wall -o window.exe win32.c -lWs2_32
I get:
win32.c: In function ‘main’:
win32.c:13:2: error: ‘KEYBDINPUT’ undeclared (first use in this function)
win32.c:13:2: note: each undeclared identifier is reported only once for each function it appears in
win32.c:13:13: error: expected ‘;’ before ‘kbi’
win32.c:14:2: error: ‘kbi’ undeclared (first use in this function)
win32.c:20:2: error: ‘INPUT’ undeclared (first use in this function)
win32.c:20:8: error: expected ‘;’ before ‘input’
win32.c:21:2: error: ‘input’ undeclared (first use in this function)
win32.c:21:15: error: ‘INPUT_KEYBOARD’ undeclared (first use in this function)
I have no idea how to fix tihis. According the documentation it's declared in Winuser.h header. But don't works for me.
#define _WIN32_WINNT 0x0403
#include <windows.h>
Seems this is the magic #define you need somewhere in your project (either explicitly in code, or via compiler command line param -D).
Note that windows.h includes winuser.h, so there's no need to include that, as it's included already for you. Also, the WIN32_LEAN_AND_MEAN define only has any effect if it's included before windows. Details about what it does here; it's not needed or particularly useful these days.
--
So what's going on here? Looking for the definition of KBDINPUT in winuser.h (C:\Cygwin\usr\include\w32api\winuser.h), we see:
#if (_WIN32_WINNT >= 0x0403)
typedef struct tagMOUSEINPUT {
...
} MOUSEINPUT,*PMOUSEINPUT;
typedef struct tagKEYBDINPUT {
...
That's the problem; these only get defined if _WIN32_WINNT is greater than 0x0403.
Those are the files from the cygwin package. Interestingly, the winuser.h from the Microsoft SDK (usually installed in C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\WinUser.h) uses a different condition:
#if (_WIN32_WINNT > 0x0400)
...which explains Jay's suggestion - he's likely looking at the MS files, where 0x0401 would be sufficient here; and also explains why it's not working for you - you're likely using the cygwin ones with a higher version requirement. As to why these two files are different - I've no idea there...
I guess you need to add
#define _WIN32_WINNT 0x0401
#include <windows.h>
#include <winuser.h>
before including windowsh and winuser.h in your source.
This is an issue with older IDEs like VC6, I tried the above and it didn't work. I had to supply the flag on project settings.
Go to Setting >> C/C++ tab >> select 'General' from Catagory combo box
add /D _WIN32_WINNT=0x401 to Project settings edit box. That's for VC6.
/d is how you supply the flag and the actual flag is _WIN32_WINNT=0x401. I do had to set it to 0x401, other values like 0x0500 were causing more errors.
I can't figure why the following code gives compilation error as if the typedef definition not found. In fact, if I add the line 'typedef TCHAR my_tchar;' (which is already in win32def.h) in app.h the compilation goes well.
win32def.h
#ifndef win32def_h
#define win32def_h
#include <tchar.h>
typedef TCHAR my_tchar;
#endif
app.h
#include "win32def.h"
int my_function(const my_tchar *filename, ....)
compilation error at line of my_function:
error C2143: syntax error : missing ')' before '*'
what the compiler is used?
I'm not sure, but try to turn on the option "treat wchar_t as built-in type".