I have project lets say PROJECT in C. It contains a number of header files and source files. I build the project in following way
File->New->project from external files
I gave the location of the project files and Name of the project.
Choose the option as Console
and then finish
The project is seen in the solution bar with
external dependencies, header and source file.
When I build it i get error in header file such as
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/_types.h(15): error C2054: expected '(' to follow '__extension__'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stddef.h(73): error C2085: '__threadid' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stddef.h(75): error C2085: '__threadhandle' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/_types.h(37): error C2085: '_flock_t' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/_types.h(40): error C2085: '_iconv_t' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/unistd.h(15): error C2082: redefinition of formal parameter '_environ'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/unistd.h(17): error C2082: redefinition of formal parameter '_exit'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/unistd.h(19): error C2085: 'access' : not in formal parameter list
What can be the reason for it?
The __extension__ keyword is used by gcc to indicate that you know that something is an extension but want to use it anyway, and request the compiler not to warn about that.
http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
Seems like you include some header that is gcc specific and doesn't work for MSVC.
Related
As part of upgrading a C++ (Microsoft Visual Studio 2010) with nodejs application from node 0.10.26 to node LTS 18.12.1, to compile and build C++ addons, we used node-gyp(node-gyp#9.3.1., Python version 3.11.1. and VS2019 (16.11.32929.386)), when doing node-gyp build, getting below errors:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(192,14): error C2872: 'byte': ambiguous symbol
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(191,23): message : could be 'unsigned char byte'
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\cstddef(28,12): message : or 'std::byte'
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(962,25): error C2872: 'byte': ambiguous symbol
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(191,23): message : could be 'unsigned char byte'
Please suggest possible solutions.
referred below link and tried suggestions from below link, but nothing worked.
https://developercommunity.visualstudio.com/t/error-C2872:-byte:-ambiguous-symbol/93889?ftype=problem&q=C%3A%5CProgram+Files+%28x86%29%5CWindows+Kits%5C10%5CInclude%5C10.0.19041.0%5Cshared%5Crpcndr.h%28192%2C14%29%3A+error+C2872%3A+%27byte%27%3A+ambiguous+symbol
I'm trying to compile a C program in Visual Studio 2019, I have 'Compile As' set to 'Compile as C Code (/TC)' and cstdio is not included anywhere in my project, yet it still gives me cstdio errors
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(33,1): error C2061: syntax error: identifier 'std'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(33,1): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(33,1): error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(91,1): error C2059: syntax error: '}'
I have a solution which is originally compiled for VS2015. I'm trying to compile the same code in VS2012. To do this, I've created a new solution, added these projects to the new solution and changed the project properties Platform Toolset to v110 instead of v140.
While building this solution, I am facing the error:
error C2375: 'printf' : redefinition; different linkage c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h 271
The line which seems to be causing this error is:
_Check_return_opt_ _CRTIMP int __cdecl printf(_In_z_ _Printf_format_string_ const char * _Format, ...);
I'm unable to figure out the root cause of this problem. Any help would be appreciated.
Getting this compilation error:
Error 4107 fatal error C1189: #error : ATL requires C++ compilation
(use a .cpp suffix) C:\Program Files\Microsoft Visual Studio
9.0\VC\atlmfc\include\atlbase.h 59
How to resolve this?
Exactly as the error message says. If your source file ends in .c the compiler assumes it's a straight C source which is incompatible with the C++ required for ATL. Change the filename to .cpp and it will compile.
If you really do need to stay with C then you'll have to find another library other than ATL to help you.
I'm trying to compile C code in VS2010. When I do, I get 714 errors in cmath, a file I haven't even included.
Here are the included files: http://pastebin.com/LzsDfEcr
The errors are all the same "style", e.g:
Error 711 error C2061: syntax error : identifier 'ceil' c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath 40
Error 712 error C2059: syntax error : ';' c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath 40
and then the same two errors just with another identifier.
I have Compile As C on under C/C++ -> Advanced, and all the files in the project are .c files.
<cmath> is a C++ header file. It's probably being included by some other C++ header file. Looking at your code, I can see that you're including <string> and <sstream>, both of which are C++ header files.
//#include <unistd.h> // doesn't exist in vs2010?
unistd.h is a unix header