Sign in to follow this  

Using C in vs 2005

This topic is 4018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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].

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
0) Exactly how much has to be in C, and why?
I'm guessing because it's an embedded application (the robot), he probably won't have A) any support libraries, B) a high level compiler

Share this post


Link to post
Share on other sites

This topic is 4018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this