How to compile C in Visual Studio .NET 2003 Enterprise Edition?
Hi,
I'll briefly explain my problem,I would be thankful if you immediately answer me.
I am a computer engineering student and I learn C so naturally I want to compile my C codes in
Microsoft Visual Studio .NET 2003 Enterprise Edition.
I wonder if you please explain how to compile C step by step since I couldn't compile!
I understood you but I said I will compile C not C++ also I said Visual Studio .NET 2003 Enterprise Edition not 2005.So now can you help me about this problem,please?
You're asking a rather broad question. Could you describe the steps you've taken so far in compiling a C program?
What I've understood from your question that you want only to compile *native* C code, with compliance to the Standard/ISO C Language, 1991. Here is a suggestion.
Using the `extern language linkage' should work with any Microsoft Visual Studio edition, according to my best knowledge of the way the respective compiler has been designed; you have to do:
extern "C" {
/*
insert all of your Standard/ISO C code here, that does not make use of any
of the Microsoft Visual Studio specifics
*/
} /* note the closing brace */
To be generic, you will need to do one of 2 options:
1. start your project as a "Console Project," then to be an "Empty Project."
Then select C/C++ Source/header file, and continue.
2. This should be more accurate, and of course, depends on the way
Microsoft has built the C/C++ Compiler: it is by using the pure command
line "C:\>" prompt, and to use one of the compiler options, if any, to just
only compile C code, or as indicated in the first option above.
Search for the respective docs of your Microsoft Visual Studion editon/
version for the command line compiler, most likely, "CL."
In either way, you should avoid C++ style comments, //
Avoid declaring var's and identifiers to be scatted inside the code, only at the beginning is allowed.
If you are going to submit your work as a homework class or to port it to UNIX-Like system, you may double check your work by installing the LCC (a C compiler) that is most ANSI compliance. You may find the docs and the IDE to be installed by visiting:
docs and links for implementation
http://www.cs.princeton.edu/software/lcc/
A good IDE: http://www.cs.virginia.edu/~lcc-win32/
Hope this helps you out.
Good tips. For those interested in making sure their VC++ code compiles cleanly under Unix, note that the Gnu compiler (GCC) is the mainstream compiler for Unix.
There are a lot of compilers out there that are highly ANSI C and ISO C++ conformant, to the point where you have to be "power user" to write code that might behave differently. The biggest time consumption, in my experience, comes from the fact that diagnostics (warnings and errors) are not standardized across compilers. What one compiler accepts under certain warning levels, another complains, and vice-versa. So I would go with whatever compiler you're using on your target platform, not just one that is merely complaint.
With that in mind, I would recommend using Cygwin. While a lot of people use it for its BASH shell, I use it because it has the latest Gnu compiler plus a lot of Unix commands that I need to run on my Windows desktop.
Brian
You don't have to do anything special: just create a project as you would for a C++ project but instead of adding *.cpp files to the project you should add *.c files (or even a mixture of *.cpp and *.c) . The compiler driver (cl.exe) will then ensure that the correct compiler is invoked (c1.dll instead of c1xx.dll).
RE: C Compiler Implementation >> Diagnostics: Warning and ErrorsWhen writing a compiler for a language, there is no specific way of how to generate the "target" code. The major issue is how the source is being "parsed," top-down or bottom-up. All subsequent stages depend on this build. In all compiler design theory, and all WW standardizations and locals, e.g. ANSI, there is no way of how to implement syntax errors; it's totally left to the compiler writer/designer.
In general, there are some algorithms for detecting (syntax) errors, if the parsing technique implemented, for a given compiler, is known. Based on this information, a programmer may familiarize him-/her-self of how the compiler detected such errors.
Most C compilers use either "recursive-descent, predective parsers," as a top-down, or any of the bottom-up, LR parsers. To spot out errors, it is best to know how the compiler has been designed.
LCC as the "retagetable" compiler that has been designed by Fraser and Hanson, documented in their book, ISBN: 0-8053-1670-1, and not other implementations, is the most well-known that complies with the ANSI C.
Regards.