C2143, unable to understand the cause...

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 106
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 4
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

C2143, unable to understand the cause...

 
0
  #1
Mar 19th, 2009
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:
  1. extern "C" { // to allow the low-level C functions to be compiled
  2. #include "console.h" // by the C compiler only
  3. }
  4.  
  5. #include "screen.h"
  6. #include <iostream>
  7. #include <cstdlib>
  8. #include <new>
  9. using namespace std;

And similarly in Screen.cpp
  1. /*Above are just comments*/
  2. extern "C" { // to allow the low-level c functions to be compiled
  3. #include "console.h" // by the c compiler only
  4. }
  5.  
  6. #include "screen.h"
  7. #include <cstdlib>
  8. #include <iostream>
  9. #include <new>
  10. 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.
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,847
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 298
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: C2143, unable to understand the cause...

 
0
  #2
Mar 19th, 2009
C-functions will compile just fine in vs2008, so just lose the extern "c"
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 106
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 4
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: C2143, unable to understand the cause...

 
0
  #3
Mar 19th, 2009
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
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 106
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 4
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: C2143, unable to understand the cause...

 
0
  #4
Mar 19th, 2009
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.
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 106
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 4
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: C2143, unable to understand the cause...

 
0
  #5
Mar 19th, 2009
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.
Last edited by sid78669; Mar 19th, 2009 at 2:18 pm. Reason: NOTE for Googlers
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC