jorrebor
jorrebor

Reputation: 2232

How to build C source code with visual c++ express 2010?

I have C source code which i want want to build with Visual Studio 2010. It references two libraries, which i think i have added correctly to my project, see the image.

As i understand i should rename the source file to name.c in order to have compiled as C. When i build my solution I get a undefined namespace errors on AssemblyInfo.cpp.

how can i fix these errors?

Please note that I also got a .OBJ, .LIB and .MAK file with the program. When opening the .MAK file I get the following errors:

EDIT:

i recreaated the project as Win32 console project. When compile the solution I get the following errors:

1>------ Build started: Project: SerialCommWin32, Configuration: Debug Win32 ------
1>  SerialCommWin32.cpp
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\asynch_1.h(44): error C2143: syntax error : missing ',' before '*'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\asynch_1.h(73): error C2143: syntax error : missing ',' before '*'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(447): error C2664: 'wrtst_a1' : cannot convert parameter 4 from 'uint *' to 'int *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2143: syntax error : missing ';' before '{'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(491): error C2664: 'wrtst_a1' : cannot convert parameter 4 from 'uint *' to 'int *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2143: syntax error : missing ';' before '{'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(532): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(546): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(585): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(710): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(728): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(746): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(765): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(946): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1364): error C2664: 'rdst_a1' : cannot convert parameter 3 from 'uchar *' to 'char *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2143: syntax error : missing ';' before '{'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Upvotes: 0

Views: 695

Answers (1)

Botz3000
Botz3000

Reputation: 39650

The compiler probably doesn't really care for the file extensions. You could look into your project's settings: C/C++ -> Advanced -> Compile As and then select C Code (although valid C code should also be valid C++ code).

Also, the AssemblyInfo.cpp is only for C++/CLI projects. So remove that file or exclude it from the build.

It looks like created the project as a C++/CLI project, so you'll probably have to edit more project settings, or (the best solution IMO) recreate the project file as a native C/C++ project (Like Win32 Project or Win32 Console Application).

Upvotes: 2

Related Questions