User | Post |
MathOnNapkins
Posts: 125/2189 |
Originally posted by xZeaLitYx How does one run .cpp files?
Sorry Zeality but every time I look at this I get a chuckle. |
neotransotaku
Posts: 470/4016 |
okay, i missed a return statement... but still, gcc will compile that code and that same code will compile when i use .cpp extension in visual studio 6, but will not compile if i use .c
if you want to write universal c code, then you should just use ANSI C compiler |
Kegan Marius
Posts: 14/18 |
Originally posted by neotransotaku
Originally posted by Jagori It can? I'm using MS Visual C++ 6.0 and I can't find it... where would I be able to change this setting? (and I've tried just straight up compiling a C file, and it didn't work). Even if it does work, that's still the reason I got Bloodshed
if you want to compile in C mode for Visual Studio without setting anything, you must do the following:
1) have your file end in .C 2) make sure EVERYTHING is declared before you use it
the following code will not compile in C mode
int main() { int x = 0; x = x + x; int y; }
however, if the file that was in ended in .cpp, then you will have no problems. the interesting thing is if you use gcc, then you can declare stuff, well local variables anyways, anywhere you want...
That code wouldn't compile anywhere; you missed the return statement. And unless you're in Windows, which has case-insensitive names, .C is considered C++ as well.
It's also a bad idea to rely on GCC extensions to the C (and C++) language. Chances are the code you write with said extensions won't compile anywhere else. Same goes for VC++, thought the .Net 2003 version is EXTREMELY good about keeping to the standards. |
neotransotaku
Posts: 468/4016 |
Originally posted by Jagori It can? I'm using MS Visual C++ 6.0 and I can't find it... where would I be able to change this setting? (and I've tried just straight up compiling a C file, and it didn't work). Even if it does work, that's still the reason I got Bloodshed
if you want to compile in C mode for Visual Studio without setting anything, you must do the following:
1) have your file end in .C 2) make sure EVERYTHING is declared before you use it
the following code will not compile in C mode
int main() { int x = 0; x = x + x; int y; }
however, if the file that was in ended in .cpp, then you will have no problems. the interesting thing is if you use gcc, then you can declare stuff, well local variables anyways, anywhere you want... |
Kegan Marius
Posts: 13/18 |
Turn off language extensions. That should do it. I know VC++ 7 has an explicit "compile as C" option but VC++ 6 doesn't. It SHOULD automatically compile as C code if the extension is .c, though. |
Jagori
Posts: 11/267 |
It can? I'm using MS Visual C++ 6.0 and I can't find it... where would I be able to change this setting? (and I've tried just straight up compiling a C file, and it didn't work). Even if it does work, that's still the reason I got Bloodshed |
Cellar Dweller
Posts: 42/269 |
Originally posted by Kegan Marius Case in point: you can get the Microsoft Visual C++ .Net 2003 optimizing compiler and linker for free now at microsoft.com. It's missing a few features, like no IDE, debugger, or profiler, and there's no STL, DirectX, or OpenGL libraries, but if you're only looking for a plain C++ compiler this works.
Before compiling GUI apps you need the Windows SDK. It is also available for free from Microsoft.
I think that the free compiler does come with STL.
Originally posted by Jagori I use Bloodshed Dev C++. Actually, I normally use MS Visual Studio for C++, but I got Bloodshed because it can also compile C. Very good free IDE.
You can compile C with Visual Studio. Any adequate C++ compiler should support a C mode and compile C in both C and C++ modes. |
Jagori
Posts: 10/267 |
I use Bloodshed Dev C++. Actually, I normally use MS Visual Studio for C++, but I got Bloodshed because it can also compile C. Very good free IDE. |
Kegan Marius
Posts: 12/18 |
Case in point: you can get the Microsoft Visual C++ .Net 2003 optimizing compiler and linker for free now at microsoft.com. It's missing a few features, like no IDE, debugger, or profiler, and there's no STL, DirectX, or OpenGL libraries, but if you're only looking for a plain C++ compiler this works. |
neotransotaku
Posts: 451/4016 |
there are free C++ compilers out there, just do a search for them on google. |
Dish
Posts: 38/596 |
you don't. cpp is the extension for C++ source files.
You can get a C++ compiler and compile the cpp files to form an exe, which you can run. |
xZeaLitYx
Posts: 6/199 |
How does one run .cpp files? I've downloaded CCTools for extracting the Chrono Cross script, but they're all .cpp. |