Using C in vs 2005
Hi guys,
Im writing some code for a robot project in C. Sadly our robot hasnt shipped yet so I have to program it without and visualize the results. Has to be in C and Id like to use MFC dialogs for the output.
1. What exactly cant I use in my vs 2005 dev environment to make sure Im sticking to plain C. No classes, no std, malloc/free anything else?
2. Will just naming my files *.c make the compiler interpret the code as c and thus give me errors when using c++?
Thanks guys
-CProgrammer
1. Indeed no classes, no std. Malloc and free are useable, but new and delete aren't. Variable declarations need to be done at the top of the function.
2. Go to Configuration Properties -> C/C++ -> Advanced, then change the Compile As option to 'Compile as C code (/TC)'.
Don't know if you can use MFC in plain C (I think not), so I'd make two projects: a static plain-C library containing your robot code, and a C++-MFC application that does the visualization and links to the C-code. But that might have been your plan all along [smile].
2. Go to Configuration Properties -> C/C++ -> Advanced, then change the Compile As option to 'Compile as C code (/TC)'.
Don't know if you can use MFC in plain C (I think not), so I'd make two projects: a static plain-C library containing your robot code, and a C++-MFC application that does the visualization and links to the C-code. But that might have been your plan all along [smile].
Thanks the c compile function is great.
O my god, no functions in structs. Arg the pain.
Does that mean the best way is to have all member functions declared global and taking teh struct as param? Oh my...
O my god, no functions in structs. Arg the pain.
Does that mean the best way is to have all member functions declared global and taking teh struct as param? Oh my...
Quote:Original post by DaBonoIndeed. MFC stands for Microsoft Foundation Classes and it's C++ only.
Don't know if you can use MFC in plain C (I think not)
0) Exactly how much has to be in C, and why?
1) There are quite a few differences between the languages, many of which are not commonly mentioned.
1) There are quite a few differences between the languages, many of which are not commonly mentioned.
MSVC defaults to looking at the file extension to to figure out what language you're using, so yes just naming it .c is enough in the vast majority of cases. If it's named .cpp, .cxx, or a few others then it will compile as C++.
The switch DaBono mentioned is there for wierd cases or for those people who absolutely positivitely want to be 100% double-sure.
The switch DaBono mentioned is there for wierd cases or for those people who absolutely positivitely want to be 100% double-sure.
Quote:Original post by ZahlmanI'm guessing because it's an embedded application (the robot), he probably won't have A) any support libraries, B) a high level compiler
0) Exactly how much has to be in C, and why?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement