473,509 Members | 12,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fix "expected identifier or '(' before '{' token" errors?

3 New Member
When trying to compile I get this

/main.c:30: error: expected identifier or '(' before '{' token
../main.c:31: error: expected identifier or '(' before 'if'
make: *** [main.o] Error 1

Expand|Select|Wrap|Line Numbers
  1. SDL_SysWMinfo info;
  2. SDL_VERSION(&info.version);
  3. if ( SDL_GetWMInfo(&info) ) {
  4.   Display *dpy = info.info.x11.display;
  5.   Window win;
  6.  
These are the lines, line 30 and 31 are the second SDL one and the if (... one.

I tried changing anythign around there, but it doesn`t
seem to work. Any ideas?

Thanks!
Feb 25 '11 #1
5 26242
Jason Mortmer
23 New Member
You have to put a closing brace '}' at the end of the function.
Feb 25 '11 #2
donbock
2,426 Recognized Expert Top Contributor
SDL_VERSION is a macro that, in your case, will expand to something like this:
Expand|Select|Wrap|Line Numbers
  1. {
  2.     (&info.version)->major = SDL_MAJOR_VERSION;
  3.     (&info.version)->minor = SDL_MINOR_VERSION;
  4.     (&info.version)->patch = SDL_PATCHLEVEL;
  5. }
I think both of the warnings are complaining about the curly braces generated by the macro. I don't see anything wrong here. Perhaps your version of the macro expands to something slightly different than this.

Try the following as an experiment: change line 2 from
Expand|Select|Wrap|Line Numbers
  1. SDL_VERSION(&info.version); 
to
Expand|Select|Wrap|Line Numbers
  1. do SDL_VERSION(&info.version) while(0);
My suggestion is a travesty -- please don't leave it like that even if the warnings go away.

Which compiler are you using?
Feb 27 '11 #3
Phacer
3 New Member
Well, somehow the error seems to have gone, and
I don`t know why.
I think it`s crazy, but restarting the pc made it go...?
Anyway, now I get a new error..

Expand|Select|Wrap|Line Numbers
  1. cc1plus: warning: command line option "-std=c99" is valid for C/ObjC but not for C++
  2. In file included from ../main.c:20:
  3. ../common.h:105:19: error: SDL.h: No such file or directory
  4. In file included from ../common.h:245
even tough I don't have c++ files, nor mentions on
makefile or any of the project files...
Feb 28 '11 #4
donbock
2,426 Recognized Expert Top Contributor
The errors aren't gone -- this new problem is masking the old one.

What compiler are you using?
How are you invoking it?
Feb 28 '11 #5
Phacer
3 New Member
In fact, I was making a silly mistake on my
c sufixes on my makefile =)
Thanks for everyone`s help!
Mar 2 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
5211
by: Grzegorz Dostatni | last post by:
Good morning. I've got a Tkinter problem: File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 2310, in selection_present return self.tk.getboolean( TclError: expected boolean value but got "" ...
10
7580
by: Ian Lazarus | last post by:
Hello. How do "unresolved token" link errors occur. How do I fix them? Linking... LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@ LINK : error LNK2020: unresolved token...
8
2724
by: trappedIntoCode | last post by:
Hi Everyone, Here is a part of javascript code that works well in FF2 but shows above error in IE6 and error "missing name after . operator" . function...
7
92002
by: Warrax | last post by:
I am currently doing online tutorials for C++, and am pretty much stuck in a rut about this problem. It is saying that there's an expected unqualifed-id before '{' token (I will post the code in just...
1
3248
by: nagaraj | last post by:
In Dev C++, we tried to compile a application, but it will throw some peculiar error. please find it below "path/main.cpp expected `]' before ';' token" and the source code is "DWORD rtec_Stack...
9
11155
by: Rohit | last post by:
I am trying to initialize an array whose initializers depend on value of Enums. I take enum and then decide the initializer value, so that even if enum value changes because of addition to list...
1
3655
by: mikr | last post by:
I'm new to jquery, and hoping it will make my client side coding more friendly (particularly with regards to ie). As is usually the case, I've got some code that works nicely in ff, but kicks out...
2
11906
by: Bryan Vargas | last post by:
I keep getting the same "expected indented block" when ever I run my code. from myro import* init("simulator") def main(): for x in range(10): #repeats code in loop 10 times
1
10838
by: Amjad Raza Gill | last post by:
I am facing this problem during the migration from oracle to db2, pls. help to remove this error. I am new to DB2. DB21034E The command was processed as an SQL statement because it was not a ...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.