Solved

help with strange compile error C2014

Posted on 2003-11-10
7
1,628 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…

706 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

21 Experts available now in Live!

Get 1:1 Help Now