Building C code in Visual C++ Express - c++

Quite a while back I was playing around with C code for a POS device. I could develop and build in Visual Studio 2008. Then to test I could go into cygwin, make the code and load onto the device, or use the included simulator. Somewhere along the lines that virtual box was lost.
I want to start up again in dabbling with this device but am having an awful time trying to get the code to build in Visual Studio 2008 C++ Express.
I created a new project from existing code, set it to compile as C code and tried to build. It complained that it could not find system.h, so I added the directory in the include directories under tools.
Now it gives 408 errors. Example as shown below:
------ Build started: Project: TestHelloWorld, Configuration: Debug Win32 ------
Compiling...
sysutil.c
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(105) : error C2054: expected '(' to follow '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(105) : error C2085: 'disable_interrupt' : not in formal parameter list
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(106) : error C2082: redefinition of formal parameter '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(106) : error C2143: syntax error : missing ';' before 'type'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(106) : error C2085: 'enable_interrupt' : not in formal parameter list
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(107) : error C2085: 'call_app_func' : not in formal parameter list
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(108) : error C2082: redefinition of formal parameter '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(108) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(108) : error C2146: syntax error : missing ',' before identifier 'os_switch_app'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(108) : error C2143: syntax error : missing ';' before '('
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(108) : error C2059: syntax error : ')'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(109) : error C2054: expected '(' to follow '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(109) : error C2085: 'app5_call' : not in formal parameter list
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(110) : error C2082: redefinition of formal parameter '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(110) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(110) : error C2146: syntax error : missing ',' before identifier 'app6_call'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(110) : error C2143: syntax error : missing ';' before '('
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(110) : error C2059: syntax error : ')'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(111) : error C2054: expected '(' to follow '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(111) : error C2085: 'app7_call' : not in formal parameter list
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(112) : error C2082: redefinition of formal parameter '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(112) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(112) : error C2146: syntax error : missing ',' before identifier 'app8_call'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(112) : error C2143: syntax error : missing ';' before '('
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(112) : error C2059: syntax error : ')'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(113) : error C2054: expected '(' to follow '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(113) : error C2085: 'app9_call' : not in formal parameter list
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(114) : error C2082: redefinition of formal parameter '__pcs'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(114) : error C2146: syntax error : missing ',' before identifier 'DWORD'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(114) : error C2146: syntax error : missing ',' before identifier 'app10_call'
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(114) : error C2143: syntax error : missing ';' before '('
c:\cygwin\home\creon_sdk_v2.3\program\lib\system.h(114) : error C2059: syntax error : ')'
Does anybody have any idea how I can get this working.
The code is from the sample code that comes with the SDK for the device.
Also the SDK comes with cygwin which is installed and I can make the sample program no problem, however I am more of a C# developer and so like my IDE. I had this working before but cannot remember how I got it working before.
Please, any suggestions would be appreciated.
Kind regards,
Neill
Edit - As request line 101 - 115 from system.h
#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#include "common.h"
extern __pcs void disable_interrupt();
extern __pcs void enable_interrupt();
extern DWORD call_app_func(void * ptr,DWORD param1,DWORD param2,DWORD param3);
extern __pcs DWORD os_switch_app(BYTE app_id,DWORD param1,DWORD param2,DWORD param3);
extern __pcs DWORD app5_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app6_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app7_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app8_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app9_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
extern __pcs DWORD app10_call(DWORD func_no,DWORD param1,DWORD param2, DWORD param3);
Thanks!

This particular compiler error message of the form of error C2054: expected '(' to follow '__pcs' indicates that the compile is attempting to decode the line of source as if __pcs is the beginning of a function name and it is expecting parenthesis to follow the identifier because it is expecting a function parameter list.
Whenever I have seen this it is because there is a define missing which will define __pcs to some function behavior modifier. For instance in Windows you may have something that will specify the calling sequence (C standard versus Pascal) or another one will be for DLL linkage.
I suggest you do a search through your header files looking for a define for __pcs to see where it might be defined.
It really looks like there is some kind of a -D compiler directive to define __pcs or a header file that needs to be included to define __pcs.
Here is a sample header file include dependency graph for a Cygwin application that might be helpful.

Related

C syntax - error C2143: syntax error : missing ')' before '*' [duplicate]

This question already has answers here:
Is bool a native C type?
(12 answers)
Closed 6 years ago.
Why am I getting a syntax error for my C header declaration?
Here is my header file, viterbi.h:
#ifndef VITERBI_H
#define VITERBI_H
void vitdec(float* , int , int , bool* );
#endif //VITERBI_H
And here is my implementation file, viterbi.c:
// viterbi.c : Defines the entry point for the console application.
//
#include "viterbi.h"
#include "math.h"
//void vitdec(float* sd, int frameLen, int rate, bool* hd);
void vitdec(float* sd, int frameLen, int rate, bool* hd)
{
//... The rest of the function
The errors from the Visual Studio 2010 compiler read:
viterbi.h(4): error C2143: syntax error : missing ')' before '*'
viterbi.h(4): error C2081: 'bool' : name in formal parameter list illegal
viterbi.h(4): error C2143: syntax error : missing '{' before '*'
viterbi.h(4): error C2059: syntax error : ')'
viterbi.h(4): error C2059: syntax error : ';'
viterbi.c(7): error C2065: 'bool' : undeclared identifier
viterbi.c(7): error C2065: 'hd' : undeclared identifier
viterbi.c(7): warning C4552: '*' : operator has no effect; expected operator with side-effect
As far as I have seen/can tell, this is valid syntax for a C declaration. If I compile viterbi.c as C++ code (viterbi.cpp), then the errors disappear. What is the syntax error?
bool is not a native C type, but for those using C99, try adding the line #include <stdbool.h>, which contains a macro that defines bool.
Since the C compiler in all Visual Studio/MSVC products uses C89, bool is not defined at all for you, as a native C type or otherwise. Workarounds include using typedef or enum to define bool. Examples are in the below link.
For more information, see: Is bool a native C type?

EnterCriticalSection identifier not found

Ok, I'm compiling a project that is using the Chromium Embedded Framework 3. I'm using Windows 7 64-bit with Visual Studio 2013 RC. Officially, VS2013 RC is not supported by CEF3. However, I require VS2013 due to C++11 features that are only available in VS2013.
I downloaded the CEF3 64 bit binaries, and compiled their sample application using VS2013. It worked beautifully (although I had to add the <algorithm> header file to some of the cef3 header files).
Now, when I include some of the CEF3 files into my project, I'm getting a bunch of compile errors. I'm using SCons to compile my project. It looks almost like some variables and defines are not getting set/called when the CEF3 header file(s) include the <windows.h> header file...
The errors are:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fobuild\gui\GUI.obj /c src\gui\GUI.cpp /TP /w /wd4350 /EHsc /MD /DDEBUG /DPACKAGE_VERSION=\"0.0.1\" /DPACKAGE_BUGREPORT=\"https://github.com/jarrettchisholm/glr/issues\" /DBOOST_SPIRIT_USE_PHOENIX_V3
cl /Fobuild\gui\HtmlGuiComponent.obj /c src\gui\HtmlGuiComponent.cpp /TP /w /wd4350 /EHsc /MD /DDEBUG /DPACKAGE_VERSION=\"0.0.1\" /DPACKAGE_BUGREPORT=\"https://github.com/jarrettchisholm/glr/issues\" /DBOOST_SPIRIT_USE_PHOENIX_V3
GUI.cpp
HtmlGuiComponent.cpp
cl /Fobuild\models\ModelManager.obj /c src\models\ModelManager.cpp /TP /w /wd4350 /EHsc /MD /DDEBUG /DPACKAGE_VERSION=\"0.0.1\" /DPACKAGE_BUGREPORT=\"https://github.com/jarrettchisholm/glr/issues\" /DBOOST_SPIRIT_USE_PHOENIX_V3
ModelManager.cpp
cl /Fobuild\glw\Animation.obj /c src\glw\Animation.cpp /TP /w /wd4350 /EHsc /MD /DDEBUG /DPACKAGE_VERSION=\"0.0.1\" /DPACKAGE_BUGREPORT=\"https://github.com/jarrettchisholm/glr/issues\" /DBOOST_SPIRIT_USE_PHOENIX_V3
Animation.cpp
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(55) : error C2146: syntax error : missing ';' before identifier 'instance'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(55) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(70) : error C2146: syntax error : missing ';' before identifier 'parent_window'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(70) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(71) : error C2146: syntax error : missing ';' before identifier 'menu'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(71) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(86) : error C2146: syntax error : missing ';' before identifier 'window'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(86) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types.h(83) : error C2371: 'char16' : redefinition; different basic types
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_string_types.h(51) : see declaration of 'char16'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(65) : error C2146: syntax error : missing ';' before identifier 'm_sec'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(65) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(52) : error C2065: 'm_sec' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(52) : error C2065: 'CRITICAL_SECTION' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(52) : error C2070: 'unknown-type': illegal sizeof operand
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(53) : error C2065: 'm_sec' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(53) : error C3861: 'InitializeCriticalSection': identifier not found
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(56) : error C2065: 'm_sec' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(56) : error C3861: 'DeleteCriticalSection': identifier not found
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(59) : error C2065: 'm_sec' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(59) : error C3861: 'EnterCriticalSection': identifier not found
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(62) : error C2065: 'm_sec' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(62) : error C3861: 'LeaveCriticalSection': identifier not found
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(84) : error C2039: 'instance' : is not a member of '_cef_main_args_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(54) : see declaration of '_cef_main_args_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(54) : see declaration of '_cef_main_args_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(96) : error C2061: syntax error : identifier 'HINSTANCE'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(96) : error C2535: 'CefMainArgs::CefMainArgs(void)' : member function already defined or declared
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(93) : see declaration of 'CefMainArgs::CefMainArgs'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(97) : error C2065: 'instance' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(97) : error C2065: 'hInstance' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(120) : error C2039: 'parent_window' : is not a member of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(61) : see declaration of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(61) : see declaration of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(121) : error C2039: 'menu' : is not a member of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(61) : see declaration of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(61) : see declaration of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(122) : error C2039: 'window' : is not a member of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(61) : see declaration of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_types_win.h(61) : see declaration of '_cef_window_info_t'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(139) : error C2061: syntax error : identifier 'HWND'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(149) : error C2061: syntax error : identifier 'HWND'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(165) : error C2061: syntax error : identifier 'HWND'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(140) : error C2065: 'WS_CHILD' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(140) : error C2065: 'WS_CLIPCHILDREN' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(140) : error C2065: 'WS_CLIPSIBLINGS' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(140) : error C2065: 'WS_TABSTOP' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(141) : error C2065: 'WS_VISIBLE' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(142) : error C2065: 'parent_window' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(142) : error C2065: 'hWndParent' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(143) : error C2065: 'windowRect' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(143) : error C2228: left of '.left' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(144) : error C2065: 'windowRect' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(144) : error C2228: left of '.top' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(145) : error C2065: 'windowRect' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(145) : error C2228: left of '.right' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(145) : error C2228: left of '.left' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(146) : error C2065: 'windowRect' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(146) : error C2228: left of '.bottom' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(146) : error C2228: left of '.top' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(150) : error C2065: 'WS_OVERLAPPEDWINDOW' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(150) : error C2065: 'WS_CLIPCHILDREN' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(150) : error C2065: 'WS_CLIPSIBLINGS' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(151) : error C2065: 'WS_VISIBLE' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(152) : error C2065: 'parent_window' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(152) : error C2065: 'hWndParent' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(153) : error C2065: 'CW_USEDEFAULT' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(154) : error C2065: 'CW_USEDEFAULT' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(155) : error C2065: 'CW_USEDEFAULT' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(156) : error C2065: 'CW_USEDEFAULT' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(158) : error C2065: 'windowName' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(158) : error C2228: left of '.c_str' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(158) : error C2228: left of '.length' must have class/struct/union
type is 'unknown-type'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(158) : error C2660: 'cef_string_utf16_set' : function does not take 3 arguments
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(167) : error C2065: 'parent_window' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(167) : error C2065: 'hWndParent' : undeclared identifier
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_base.h(98) : error C3861: 'InterlockedIncrement': identifier not found
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_base.h(105) : error C3861: 'InterlockedDecrement': identifier not found
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(287) : error C2146: syntax error : missing ';' before identifier 'GetWindowHandle'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(287) : error C2433: 'CefBrowserHost::HWND' : 'virtual' not permitted on data declarations
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(287) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(295) : error C2146: syntax error : missing ';' before identifier 'GetOpenerWindowHandle'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(295) : error C2433: 'CefBrowserHost::HWND' : 'virtual' not permitted on data declarations
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(295) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(468) : error C2061: syntax error : identifier 'MSG'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(474) : error C2061: syntax error : identifier 'MSG'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(287) : error C2253: 'CefBrowserHost::GetWindowHandle' : pure specifier or abstract override specifier only allowed on virtual function
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_browser.h(295) : error C2253: 'CefBrowserHost::GetOpenerWindowHandle' : pure specifier or abstract override specifier only allowed on virtual function
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_keyboard_handler.h(59) : error C2061: syntax error : identifier 'MSG'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_keyboard_handler.h(71) : error C2061: syntax error : identifier 'MSG'
C:\Users\Jarrett\projects\cef_binary_3.1547.1412_windows64\include/cef_render_handler.h(129) : error C2061: syntax error : identifier 'HCURSOR'
src\gui\HtmlGuiComponent.cpp(179) : error C2082: redefinition of formal parameter 'clickCount'
scons: building terminated because of errors.
Some errors that jump out at me are:
\cef_binary_3.1547.1412_windows64\include/internal/cef_win.h(59) : error C3861: 'EnterCriticalSection': identifier not found
But this should be found, as cef_win.h clearly includes <windows.h> before it tries to call EnterCriticalSection.
There are various other errors that seem like they shouldn't be occuring.
I created a simple little sample file, which includes that same CEF3 header files that my project uses, and compiled using SCons, and it compiled just fine. The sample app is below:
/* Sample C/C++, Windows, link to kernel32.dll */
#include <cef_app.h>
#include <cef_client.h>
#include <cef_render_handler.h>
static CRITICAL_SECTION cs; /* This is the critical section object -- once initialized,
it cannot be moved in memory */
/* If you program in OOP, declare this as a non-static member in your class */
void f()
{
/* Enter the critical section -- other threads are locked out */
EnterCriticalSection(&cs);
/* Do some thread-safe processing! */
/* Leave the critical section -- other threads can now EnterCriticalSection() */
LeaveCriticalSection(&cs);
}
int main()
{
/* Initialize the critical section before entering multi-threaded context. */
InitializeCriticalSection(&cs);
f();
/* Release system object when all finished -- usually at the end of the cleanup code */
DeleteCriticalSection(&cs);
return 0;
}
Anyone have any ideas why I would be getting these errors?
as per comments: windows.h file wasn't included, because other script defined _WINDOWS_

How to use c++ objects in Delphi

I am making a DLL file for delphi applicaton in visual studio. I am following http://rvelthuis.de/articles/articles-cppobjs.html link to make the dll.My code is as follows
DLL_CLASS.h
#pragma once
using namespace std ;
#include "stdafx.h"
class DLL_CLASS
{
private:
public:
int TestValue;
char* getConnectedInverters (char* path);
char* getInverterParameters (int Device_Handle);
char* getInverter_SPOT_READINGS(int Device_Handle);
char* getPassword_varification();
char* get_Inverter_password();
char* get_Device_name(int Device_handle);
int get_Device_handel();
char* setAllInverterParameters(int Device_Handle,char* path_to_XML);
char* setYasdi_Reset_and_Shutdown();
char* get_Encryption(char* string_to_encrypt);
char* deviceXmlname();
char* RegExp(string Device_type);
int Get_inst_code_Channel(int Device_Handle);
char* set_One_InverterParameters(int Device_Handle,int Channel_handle,string Value);
DLL_CLASS();
virtual ~DLL_CLASS();
};
and other file code is as below
#include "stdafx.h"
#include "DLL_CLASS.h"
#include <tchar.h>
#include <windows.h>;
// define a macro for the calling convention and export type
#define EXPORTCALL __declspec(dllexport) __stdcall
typedef DLL_CLASS *ConsoleHandle;
extern "C"
{
ConsoleHandle EXPORTCALL NewConsole(void)
{
return new DLL_CLASS();
}
void EXPORTCALL DeleteConsole(ConsoleHandle handle)
{
delete handle;
}
char* EXPORTCALL NEW_getConnectedInverters(ConsoleHandle handle ,char* path)
{
handle->getConnectedInverters (path);
}
char* EXPORTCALL NEW_getInverterParameters (ConsoleHandle handle ,int Device_Handle)
{
handle->getInverterParameters(Device_Handle);
}
char* EXPORTCALL NEW_getInverter_SPOT_READINGS(ConsoleHandle handle,
int Device_Handle)
{
handle->getInverter_SPOT_READINGS(Device_Handle);
}
char* EXPORTCALL NEW_getPassword_varification(ConsoleHandle handle)
{
handle->getPassword_varification();
}
char* EXPORTCALL NEW_get_Inverter_password(ConsoleHandle handle)
{
handle->get_Inverter_password();
}
char* EXPORTCALL NEW_get_Device_name(ConsoleHandle handle,
int Device_handle)
{
handle->get_Device_name(Device_handle);
}
int EXPORTCALL NEW_get_Device_handel(ConsoleHandle handle)
{
return handle->get_Device_handel();
}
char* EXPORTCALL NEW_setAllInverterParameters(ConsoleHandle handle,int Device_Handle,char* path_to_XML)
{
return handle->setAllInverterParameters( Device_Handle, path_to_XML);
}
char* EXPORTCALL NEW_setYasdi_Reset_and_Shutdown(ConsoleHandle handle)
{
handle->setYasdi_Reset_and_Shutdown();
}
char* EXPORTCALL NEW_get_Encryption(ConsoleHandle handle,
char* string_to_encrypt)
{
handle->get_Encryption(string_to_encrypt);
}
char* EXPORTCALL NEW_deviceXmlname(ConsoleHandle handle)
{
handle->deviceXmlname();
}
char* EXPORTCALL RegExp(ConsoleHandle handle,
string Device_type)
{
handle->RegExp( Device_type);
}
char* EXPORTCALL NEW_set_One_InverterParameters(ConsoleHandle handle,
int Device_Handle,int Channel_handle,string Value)
{
handle->set_One_InverterParameters( Device_Handle,Channel_handle, Value);
}
int EXPORTCALL NEW_Get_inst_code_Channel(ConsoleHandle handle,
int Device_Handle)
{
handle->Get_inst_code_Channel(Device_Handle);
}
} // extern "C"
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
But this Give me error as below
1>------ Build started: Project: inverter_library, Configuration: Release Win32 ------
1> flatten.cpp
1>flatten.cpp(5): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>flatten.cpp(26): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(27): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(27): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(31): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(32): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(32): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(36): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(38): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(38): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(42): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(43): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(43): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(47): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(48): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(48): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(52): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(54): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(54): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(63): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(64): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(64): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(68): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(69): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(69): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(73): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(75): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(75): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(78): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(79): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(79): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(82): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(84): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(84): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(87): error C2059: syntax error : '__declspec(dllexport)'
1>flatten.cpp(89): error C2143: syntax error : missing ';' before '{'
1>flatten.cpp(89): error C2447: '{' : missing function header (old-style formal list?)
1>flatten.cpp(99): warning C4068: unknown pragma
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can anyone suggest me Why this error is coming
I tried to find the solution but I could not find it....
You need to place the __declspec(dllexport) before the return value, and the __stdcall after the return value. For example:
__declspec(dllexport) int __stdcall foo(...)
Your macro places them together, after the function return value. Hence the syntax error. So if you want both in a single macro, you need a parameterized macro that takes the return type as a parameter.
It's simpler and clear to be explicit and skip the macros and write it out longhand, in my view. I suggest that you shun macros unless they give significant benefit in comparison to non-macro alternatives. In this case I see no such benefit.
Note that some of your flattening functions are missing return statements. And you also need to be clear on the lifetime of the char* pointers that you return. I trust you are already on top of that.

C++ Header file - syntax problems

I have some errors in my header file, which I don't know how to fix because I am fairly new to C++.
Here is the code of the header file:
#pragma once
typedef unsigned int uint;
class DCEncryption
{
public:
static char* manageData(char*, char*, uint);
private:
static int max(int, int);
static uint leftRotate(uint, int);
};
And here are the errors:
- dcencryption.h(12): error C2062: type 'int' unexpected
- dcencryption.h(12): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
- dcencryption.h(12): error C2760: syntax error : expected '{' not ';'
- dcencryption.h(13): error C2144: syntax error : 'uint' should be preceded by '}'
- dcencryption.h(13): error C2143: syntax error : missing ')' before ';'
- dcencryption.h(13): error C2059: syntax error : ')'
- dcencryption.h(13): error C2143: syntax error : missing ';' before ')'
- dcencryption.h(13): error C2238: unexpected token(s) preceding ';'
You are probably on Windows and you have included windef.h directly or indirectly (through windows.h, maybe) from your main .cpp file before including the shown file.
It so happens that max is a macro defined in windef.h that does not expand nicely in your context.
This can quite easily happen on some other platforms as well.

How to track down the cause of "syntax error: missing ')' before identifier" and others? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
Im writing a project in C with visual studio that contains these files:
multiThreadServer.cpp
myLib.cpp
myLib.h
The 1st (multiThreadServer.cpp) includes these
#include <WinSock2.h>
#include <Windows.h>
#include <stdio.h>
#include "myLib.h"
2nd (myLib.cpp) these
#include <WinSock2.h>
#include <stdio.h>
#include "myLib.h"
3nd (myLib.h) includes nothing
In .h file i have these functions defined:
// Starts up the server.
INT start_server(const unsigned short port);
// Accept Connections.
BOOL accept_connections();
// Accept Client.
BOOL AcceptClient(PCLIENT current_client);
// Receiver Function for the thread.
DWORD WINAPI Receiver(LPVOID lpParam);
// Receive data from client.
BOOL recv_data(PCLIENT current_client, char *buffer, int size);
// End server.
VOID end_server();
// Send data.
BOOL send_data(PCLIENT current_client, char *buffer, int size);
// Disconnect Client.
VOID disconnect_client(PCLIENT current_client);
// Send Data to all clients.
BOOL send_data_to_all(char *message);
Here is part of myLib.cpp:
typedef struct _client{
SOCKADDR_IN address; // internal data structure regarding this client
SOCKET socket; // this clients socket
BOOL connected; // is this client connected
char IP[20]; // this clients IP address
int address_length; // internal data structure regarding this client
} CLIENT, *PCLIENT;
Now, when im going to compile the whole project these annoying syntax errors returned:
1> myLib.cpp
\mylib.h(8): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(8): error C2061: syntax error : identifier 'current_client'
\mylib.h(8): error C2059: syntax error : ';'
\mylib.h(8): error C2059: syntax error : ')'
\mylib.h(14): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(14): error C2061: syntax error : identifier 'current_client'
\mylib.h(14): error C2059: syntax error : ';'
\mylib.h(14): error C2059: syntax error : ','
\mylib.h(14): error C2059: syntax error : ')'
\mylib.h(20): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(20): error C2061: syntax error : identifier 'current_client'
\mylib.h(20): error C2059: syntax error : ';'
\mylib.h(20): error C2059: syntax error : ','
\mylib.h(20): error C2059: syntax error : ')'
\mylib.h(23): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(23): error C2061: syntax error : identifier 'current_client'
\mylib.h(23): error C2059: syntax error : ';'
\mylib.h(23): error C2059: syntax error : ')'
\mylib.cpp(103): warning C4013: 'AcceptClient' undefined; assuming extern returning int
\mylib.cpp(168): warning C4013: 'recv_data' undefined; assuming extern returning int
\mylib.cpp(188): warning C4013: 'send_data' undefined; assuming extern returning int
\mylib.cpp(189): warning C4013: 'disconnect_client' undefined; assuming extern returning int
\mylib.cpp(270): error C2371: 'disconnect_client' : redefinition; different basic types
1> multiThreadServer.cpp
\mylib.h(8): error C2146: syntax error : missing ')' before identifier 'current_client'
1\mylib.h(8): error C2061: syntax error : identifier 'current_client'
\mylib.h(8): error C2059: syntax error : ';'
\mylib.h(8): error C2059: syntax error : ')'
\mylib.h(14): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(14): error C2061: syntax error : identifier 'current_client'
\mylib.h(14): error C2059: syntax error : ';'
\mylib.h(14): error C2059: syntax error : ','
\mylib.h(14): error C2059: syntax error : ')'
\mylib.h(20): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(20): error C2061: syntax error : identifier 'current_client'
\mylib.h(20): error C2059: syntax error : ';'
\mylib.h(20): error C2059: syntax error : ','
\mylib.h(20): error C2059: syntax error : ')'
\mylib.h(23): error C2146: syntax error : missing ')' before identifier 'current_client'
\mylib.h(23): error C2061: syntax error : identifier 'current_client'
\mylib.h(23): error C2059: syntax error : ';'
\mylib.h(23): error C2059: syntax error : ')'
I m searching 1.30 hour now on net but i cannot find a way to fix it.
What the problem could be ?
Alternatively to what's suggested here, you fix the problem in the header file without actually moving the definition of PCLIENT into the header:
...
struct _client;
...
// Accept Client.
BOOL AcceptClient(struct _client* current_client);
...
// Receive data from client.
BOOL recv_data(struct _client* current_client, char *buffer, int size);
...
// Send data.
BOOL send_data(struct _client* current_client, char *buffer, int size);
// Disconnect Client.
VOID disconnect_client(struct _client* current_client);
...