Visual Studio 2008 Problem

Started by
16 comments, last by RedReaper132 15 years, 2 months ago
That is the exact code, Line 5
Advertisement
What compiler are you using? I assume it's Visual Studio, but what version? The code you've posted doesn't have any errors in it.
Visual Studio 2008 Professional
I had a hunch and I thought I'd try something, and indeed it seems that you are using a .c extension on the source filename instead of .cpp, or you have the compiler option "Compile file as .c" enabled.


D:\Temp>cl hello.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

hello.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.

/out:hello.exe
hello.obj

D:\Temp>hello
Hello World!

D:\Temp>ren hello.cpp hello.c

D:\Temp>cl hello.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

hello.c
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\cstdio(25) : error C2143: syntax error : missing '{' before ':'
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\cstdio(25) : error C2059: syntax error : ':'
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Hey sly, thanks for the explanation :)

How do i change the compiler option :)
First of all, is your source file .cpp or .c? If .c, change to .cpp.

The compiler option would have been set to C++ code by default, but if you want to check it, go to the project properties, select Configuration Properties > C/C++ > Advanced and make sure that "Compile As" is set to "Compile as C++ Code".
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
The source files are C++
I have checked the compiler settings, they are correct.
Hmm strange problem.

First put

using namespace std;

after

#include <iostream>

so you can only type

cout << "fgsdg";

instead of

std::cout << "rfasdf";

and use this as main

int main (int argc, char* args[])
-----------------------------Please visit my GameDev Blog:http://red-dev.co.nr/

This topic is closed to new replies.

Advertisement