Link to home
Start Free TrialLog in
Avatar of jadecc
jadecc

asked on

help with strange compile error C2014

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









Avatar of jkr
jkr
Flag of Germany image

Hm, what is the code "around" that?
Avatar of singhi
singhi

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.
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.
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?
Avatar of jadecc

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jadecc

ASKER

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