Skip to main content
GameDev.net gamedev.net
🔒 Locked

Need Help : error: syntax error before `*' token

Started by pandaraf Apr 18, 2012 at 3:41 PM 2 replies 4.8k views
Original Post
pandaraf
pandaraf
Until this topic posted, i didn't found the solution. This thing made me told there's something wrong in the MinGW Developer Studio. Or perharps, it's only my depression blink.png .

This is the codes i wrote :

//music
Mix_Music *music = NULL
//additional musics
Mix_Chunk *muks = NULL;
Mix_Chunk *music2 = NULL;
Mix_Chunk *music3 = NULL;
Mix_Chunk *music4 = NULL;


and


void clean() {
Mix_HaltMusic();
Mix_FreeMusic( music );
Mix_FreeChunk( muks );
Mix_FreeChunk( music2 );
Mix_FreeChunk( music3 );
Mix_FreeChunk( music4 );
Mix_CloseAudio();


and


bool load_files() {
music = Mix_LoadMUS( "vq.wav" );
if( music == NULL ) { return false; }

muks = Mix_LoadWAV( "01.wav" );
music2 = Mix_LoadWAV( "02.wav" );
music3 = Mix_LoadWAV( "03.wav" );
music4 = Mix_LoadWAV( "04.wav" );
if( ( muks == NULL ) || (music2 == NULL ) || (music3 == NULL ) || (music4 == NULL ) ) { return false; }


then, the error was :

--------------------Configuration: my project - Debug--------------------
Compiling...
ini.cpp
ini.cpp:21: error: syntax error before `*' token
ini.cpp: In function `bool load_files()':
ini.cpp:223: error: `muks' undeclared (first use this function)
ini.cpp:223: error: (Each undeclared identifier is reported only once for each
function it appears in.)
ini.o - 3 error(s), 0 warning(s)


any suggest? mellow.png
Waterlimon
Waterlimon
You forgoet a ";" from first line of code.
o3o
jpetrie
jpetrie

You forgoet a ";" from first line of code.

This is correct. Your first bit of code is:

[color=#880000]//music
[color=#660066]Mix_Music[color=#000000] [color=#666600]*[color=#000000]music [color=#666600]=[color=#000000] NULL
[color="#000000"]You're missing the semicolon after the NULL.

[color="#000000"]Sometimes, when you see an error from a compiler and it points to a line that looks okay -- in this case, it's probably indicating the line
[color=#660066]Mix_Chunk[color=#000000] [color=#666600]*[color=#000000]muks [color=#666600]=[color=#000000] NULL[color=#666600];
which looks fine, you should take a look at the line (or the code) above the error. The C++ compiler processes code from the top down and certain errors confuse the parse enough that it cannot pinpoint the source of the error with complete accuracy.
pandaraf
pandaraf
Awesome! Thank You biggrin.png

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.