Solved

help with strange compile error C2014

Posted on 2003-11-10
7
1,807 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

635 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