For the last 3 days I have been trying to compile m assingment on visual studio 2008. Its giving me error:

Error 2 error C2143: syntax error : missing ';' before 'using' screen.cpp 27 Assignment_2

This is the same error its giving me in my main:

Error 1 error C2143: syntax error : missing ';' before 'using' main.cpp 9 Assignment_2

The lines are:

Main.cpp:

extern "C" {            // to allow the low-level C functions to be compiled
#include "console.h"    // by the C compiler only
}

#include "screen.h"
#include <iostream>
#include <cstdlib>
#include <new>
using namespace std;

And similarly in Screen.cpp

/*Above are just comments*/
extern "C" {            // to allow the low-level c functions to be compiled
#include "console.h"    // by the c compiler only
     }

#include "screen.h"
#include <cstdlib>
#include <iostream>
#include <new>
using namespace std;

Can some one please tell me what the error might be? console.h is the header for all the 'C' functions from my previous that I have to use in the current assignment.

C-functions will compile just fine in vs2008, so just lose the extern "c"

I commented out the part of extern C, and just used include console.h. instead of running, it gave me this error:

Error 2 error C2143: syntax error : missing ';' before 'namespace' c:\program files (x86)\microsoft visual studio 9.0\vc\include\yvals.h 528 Assignment_2

I tried to compile console.c into an object file and it compiled correctly, therefore there seems to be no syntax or similar errors in it.

OK. After spending 4 days trying to fix it, I finally found the problem. I was missing a semicolon in my screen.h header file at the very bottom! Shame on me! LOL!!

NOTE FOR ANYONE HAVING THE SAME PROBLEM:
If you are including header files and getting this error, then go and check for any missing semicolons in your header file. AND DONT PANIC!! PM me if you like.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.