Re: Problem with: #include <X11/Xlib.h>



Kevin B. McCarty wrote:
gustavo halperin wrote:

I have a code that include the file "/usr/include/X11/Xlib.h", but when I try to compile I receive the parser error, see below:
In file included from cube.cpp:32:
/usr/include/X11/Xlib.h: In function `char* XSetOMValues(_XOM*, ...)':
/usr/include/X11/Xlib.h:3578: error: parse error before `(' token
/usr/include/X11/Xlib.h: In function `char* XGetOMValues(_XOM*, ...)':
/usr/include/X11/Xlib.h:3583: error: parse error before `(' token
..............

How I can resolve this problem,

I assume that you are using the Xlib.h from the Sid or Etch libx11-dev
package, since it has definitions for the functions XSetOMValues() and
XGetOMValues() near the line numbers printed in the compiler error.
(When reporting error messages in the future, please specify whether you
are using Sarge, Etch or Sid.)

It looks to me like the compiler is complaining about the _X_SENTINEL(0)
in this code in Xlib.h:

extern char *XSetOMValues(
XOM /* om */,
...
) _X_SENTINEL(0); // <--- Line 3578

extern char *XGetOMValues(
XOM /* om */,
...
) _X_SENTINEL(0); // <--- Line 3583


The _X_SENTINEL macro is defined in /usr/include/X11/Xfuncproto.h -- try
installing the latest version of the x11proto-core-dev package that
supplies this file. (Should be version 7.0.4-3 in Sid or Etch.)
OK, I'm using Debian Sarge version, but my X is Xorg from "www.backports.org/backports.org/" version 6.9..... . This unofficial APT repository unfortunately haven't the x11proto-core-dev package, but the file /usr/include/X11/Xfuncproto.h is there but without the "_X_SENTINEL" definition.
Here is another possibility if the above suggestion doesn't work. The
definition of _X_SENTINEL includes the GNU C extension of the
"__sentinel__" attribute, but only when __GNUC__ is defined and >= 4.
Is it possible that you are using an older compiler that doesn't
recognize __sentinel__, but for some reason your build has defined
__GNUC__ to have a value of 4 or greater anyway?
I have installed the gcc version 3.3.5.
After you mail I searched for the word "__sentinel__" in "www.google.com/linux" and I find the next solution from "http://www.mail-archive.com/debutant@xxxxxxxxxxxxxxxxx/msg03457.html"; :
Just add the below code to the beginning of the file /usr/include/X11/Xlib.h"

/* _X_SENTINEL BS */
#if defined(__GNUC__) && (__GNUC__ >= 4)
# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))

# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))

#else
# define _X_SENTINEL(x)
# define _X_ATTRIBUTE_PRINTF(x,y)
#endif /* GNUC >= 4 */


Now, the compilation success, and also the executable work fine. Do you think that my problem can be considered a bug from "www.backports.org/backports.org/" ? Therefore inform to they about ? And do you think that the fix is OK ?

Thanks a lot for you help,
Gustavo
Let the list know if these suggestions don't help. It might also be
helpful if you posted the problematic file "cube.cpp".

regards,
--
I'm thinking. | \\ l\\l_ // |
_ _ | \\/ `/ `.| |
/~\\ \ //~\ | Y | | || Y |
| \\ \ // | | \| | |\ / |
[ || || ] \ | o|o | > /
] Y || || Y [ \___\_--_ /_/__/
| \_|l,------.l|_/ | /.-\(____) /--.\
| >' `< | `--(______)----'
\ (/~`--____--'~\) / U// U / \
`-_>-__________-<_-' / \ / /|
/(_#(__)#_)\ ( .) / / ]
\___/__\___/ `.`' / [
/__`--'__\ |`-' |
/\(__,>-~~ __) | |__
/\//\\( `--~~ ) _l |--:.
'\/ <^\ /^> | ` ( < \\
_\ >-__-< /_ ,-\ ,-~~->. \ `:.___,/
(___\ /___) (____/ (____) `---'


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Freeware download corrupt (?)
    ... > a list of all functions in a package that fall in that category. ... > conflict with a function of that name in a future version of the CRTL. ... > But the compiler doesn't do that, so for now we're on our own. ... I create a package with a routine in it called "highwater". ...
    (comp.os.vms)
  • Re: PL/I, COBOL, Advantages, Equivalence, et al
    ... SPARK will allow a variable to have a value that conforms ... might be that a package somewhere will look like this ... An Ada compiler may issue a warning; ... LC> Ada/SPARK support a boolean type? ...
    (comp.lang.pl1)
  • Re: How to use packages?
    ... libraries in assembly could be created and imported for use. ... package so that some very cool libraries could be created in ways that I ... This would be very wrong -- basically giving away a Lisp compiler ... For example (given the name as.exe for the assembler): ...
    (comp.lang.lisp)
  • RE: Visual studio 2003 .NET versus its own Command Prompt
    ... > package in the lab. ... > command line compiler which cames with it. ... library, which is a .lib file, for it to know where in the DLL the functions ...
    (microsoft.public.vc.language)
  • Re: Frage zu Packages und our
    ... Der Compiler selbst schaut jedoch bei einem unqualifizierten ... Laufzeit tatsächlich auf die globale (Package) Variable zugegriffen. ... von "my" ident sind - denn ein innerhalb eines Scopes deklariertes ...
    (de.comp.lang.perl.misc)