Solved

help with strange compile error C2014

Posted on 2003-11-10
7
1,686 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

813 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