cannot compile with msvc?

cannot compile with msvc?

Return to topic list

Thu Mar 10 11:41:20 2022   by   Kaina
I have been trying to compile this with MSVC but it spits out a bunch of errors, the code is definitely fine so I was thinking maybe the microsoft compiler expects a different standard or something...

C:\Program Files\Microsoft Visual Studio\2022\Community>cl /O2 planet.c /Fepla.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31104 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

planet.c
planet.c(250): error C2143: syntax error: missing ')' before '<'
planet.c(252): error C2449: found '{' at file scope (missing function header?)
planet.c(252): error C2059: syntax error: '}'
planet.c(255): error C2449: found '{' at file scope (missing function header?)
planet.c(255): error C2059: syntax error: '}'
planet.c(258): error C2449: found '{' at file scope (missing function header?)
planet.c(258): error C2059: syntax error: '}'
planet.c(261): error C2449: found '{' at file scope (missing function header?)
planet.c(261): error C2059: syntax error: '}'
planet.c(265): error C2449: found '{' at file scope (missing function header?)
planet.c(778): error C2059: syntax error: '}'
 
Thu Mar 10 15:56:40 2022   by   Torben
I think it is because MSVC tries to parse the program as a C++ program.  At least, that is what https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2143?view=msvc-170 has led me to believe.

Is there a flag for MSVC to indicate that the program is C artaher than C++?
 
Thu Mar 10 16:43:19 2022   by   Kaina
I thought that at first, and no I believe the compiler treated it as a C program. Passing /TP (to treat the file as C++) produced even more errors, and passing /TC (to treat the file as C) produced the same set of errors.
 
Thu Mar 10 17:13:33 2022   by   Kaina
I thought that at first, and no I believe the compiler treated it as a C program. Passing /TP (to treat the file as C++) produced even more errors, and passing /TC (to treat the file as C) produced the same set of errors.
 
Thu Mar 10 17:13:44 2022   by   Kaina
I thought that at first, and no I believe the compiler treated it as a C program. Passing /TP (to treat the file as C++) produced even more errors, and passing /TC (to treat the file as C) produced the same set of errors.
 

Return to topic list



New message:
Topic:
Posted by:

Type the values of the dice shown below:

Return to topic list