Solved

help with strange compile error C2014

Posted on 2003-11-10
7
1,661 Views
Last Modified: 2010-10-05
Hi

When I try this in VC++.NET:

#ifdef WIN32
     alutLoadWAVFile(sFilename, &format, &data, &size, &freq, &loop);
#else
    alutLoadWAV(sFilename, &data, &format, &size, &bits, &freq);
#endif

I get the following errors:
g:\Visual Studio Projects\C++_2003\SnowDemo\sceneFunctions02.cpp(9) : error C2014: preprocessor command must start as first nonwhite space
g:\Visual Studio Projects\C++_2003\SnowDemo\sceneFunctions02.cpp(10) : fatal error C1019: unexpected #else


The strange thing is that similar code exists in different parts of the project and those lines compile fine. Also I have absolutely no problems when I compile under linux using g++.

Thanks in advance.
jadecc









0
Comment
Question by:jadecc
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9719925
Hm, what is the code "around" that?
0
 

Expert Comment

by:singhi
ID: 9720015
can u please tell us the code before these lines, i.e. the first eight lines, the problem may be somewhere there. I think you might be having a macro and a variable with the same name.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9720173
Compiler Error C2014
preprocessor command must start as first nonwhite space

Nonwhite space characters appeared before the number sign (#) of a preprocessor directive on the same line.

Check the previous line of #ifdef WIN32, remove this line and type it again.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:jorgearias
ID: 9724854
this compilter error can be show by an error in the .h or .hpp file . can you show us the hole code. i mean, .hpp and .cpp?
0
 
LVL 1

Author Comment

by:jadecc
ID: 9726547
Great Thanks for all the responses.


The project is kind of big so I don't want to post all the text here.
Here are a few links to the code:

http://216.110.167.76/ee/SnowDemoJustFiles.zip -- this is just the .cpp and .h files ~40k

http://216.110.167.76/ee/SnowDemo.zip  -- This is the WHOLE thing graphics / sounds / VCproj sln files ~10Megs

The problem is in the scene.cpp file:

void cScene::loadSound(char *fName, int BID, int SID)
{

      printf("loading wave file: %s\n", fName);

#ifdef WIN32

      alutLoadWAVFile(fName, &format, &data, &size, &freq, &loop);
#else
      alutLoadWAV(fName, &data, &format, &size, &bits, &freq);
#endif

      //alutLoadWAVFile(fName, &format, &data, &size, &freq, &loop);

      if((ALerror = alGetError()) != AL_NO_ERROR)
      {
            printf("alutLoadWAVFile %s : %d\n", fName, ALerror);
            alDeleteBuffers(SND_BUFFERS, sndBuffer);
      }
      else
            printf("loaded WAV file %s\n, fName");
...

When comment out the #if ... #endif statements and uncomment:
//alutLoadWAVFile(fName, &format, &data, &size, &freq, &loop);
The project compiles smoothly -- but then it won't compile in linux. I just don't know...


If you want to try to compile it you will need to get the SDL, OpenAL and OpenGL libraries linked. Also keep in mind that I'm still learning C++ and some of my code may be laughable to you guys. I really appreciate the help. I upped the points to 500 for your troubles.

Thanks
jadecc

0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 9728648
When I try to open scene.cpp file in VC++ 6, it shows the following message:
Lines ending with a carriage return have been detected. These will be modified to include a line feed.

After saving this file I open it again and this message doesn't appear. Since your problem is very strange, maybe this conversion may help. By the way, other files are opened without such messages.
0
 
LVL 1

Author Comment

by:jadecc
ID: 9728746
AlexFM,

That was it!!!  I think it happened when I started using Kdevelop as my IDE in linux. It must have somehow garbled the file. I was using Anjuta before without any problems. I guess I should have never switched.

So I went back and converted the file to DOS format like you said and it compiled without a hitch. Live and Learn --- stay away from Kdevelop. Thanks a Mill!!

jadecc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now