Discussion:
C error: Expected expression
Mark Brethen
2018-11-13 13:48:39 UTC
Permalink
Having patched calculix-cgx with the OpenGL framework, I’m now getting the following error when compiling glut:

:info:build /opt/local/bin/gcc-mp-5 -O2 -Wall -Wno-narrowing -I./ -I/usr/include -I../../libSNL/src -I../../glut-3.5/src -I/usr/X11/include -c -o ../../glut-3.5/src/glut_ext.o ../../glut-3.5/src/glut_ext.c
:info:build ../../glut-3.5/src/glut_ext.c:16:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'glutExtensionSupported'
:info:build glutExtensionSupported(const char *extension)
:info:build ^
:info:build make: *** [../../glut-3.5/src/glut_ext.o] Error 1

what does this mean?

here’s line 14-17 in glut_ext.c:

/* CENTRY */
int APIENTRY
glutExtensionSupported(const char *extension)
{



Mark Brethen
***@gmail.com
Joshua Root
2018-11-13 14:11:01 UTC
Permalink
Post by Mark Brethen
:info:build /opt/local/bin/gcc-mp-5 -O2 -Wall -Wno-narrowing -I./ -I/usr/include -I../../libSNL/src -I../../glut-3.5/src -I/usr/X11/include -c -o ../../glut-3.5/src/glut_ext.o ../../glut-3.5/src/glut_ext.c
:info:build ../../glut-3.5/src/glut_ext.c:16:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'glutExtensionSupported'
:info:build glutExtensionSupported(const char *extension)
:info:build ^
:info:build make: *** [../../glut-3.5/src/glut_ext.o] Error 1
what does this mean?
/* CENTRY */
int APIENTRY
glutExtensionSupported(const char *extension)
{
The compiler sees something that looks like invalid syntax. Is APIENTRY
perhaps not defined as a macro?

- Josh
Mark Brethen
2018-11-13 14:54:46 UTC
Permalink
Here’s the rest of the code block

/* CENTRY */
int APIENTRY
glutExtensionSupported(const char *extension)
{
static const GLubyte *extensions = NULL;
const GLubyte *start;
GLubyte *where, *terminator;

/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ' ');
if (where || *extension == '\0')
return 0;

if (!extensions)
extensions = glGetString(GL_EXTENSIONS);
/* It takes a bit of care to be fool-proof about parsing the
OpenGL extensions string. Don't be fooled by sub-strings,

etc. */
start = extensions;
for (;;) {
where = (GLubyte *) strstr((const char *) start, extension);
if (!where)
break;
terminator = where + strlen(extension);
if (where == start || *(where - 1) == ' ') {
if (*terminator == ' ' || *terminator == '\0') {
return 1;
}
}
start = terminator;
}
return 0;
}

Perhaps a semicolon is needed? i.e.

int APIENTRY;
glutExtensionSupported(const char *extension)

Mark Brethen
Post by Joshua Root
Post by Mark Brethen
:info:build /opt/local/bin/gcc-mp-5 -O2 -Wall -Wno-narrowing -I./ -I/usr/include -I../../libSNL/src -I../../glut-3.5/src -I/usr/X11/include -c -o ../../glut-3.5/src/glut_ext.o ../../glut-3.5/src/glut_ext.c
:info:build ../../glut-3.5/src/glut_ext.c:16:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'glutExtensionSupported'
:info:build glutExtensionSupported(const char *extension)
:info:build ^
:info:build make: *** [../../glut-3.5/src/glut_ext.o] Error 1
what does this mean?
/* CENTRY */
int APIENTRY
glutExtensionSupported(const char *extension)
{
The compiler sees something that looks like invalid syntax. Is APIENTRY
perhaps not defined as a macro?
- Josh
Chris Jones
2018-11-13 14:57:39 UTC
Permalink
Post by Mark Brethen
Perhaps a semicolon is needed? i.e.
int APIENTRY;
glutExtensionSupported(const char *extension)
nope, that is definitely invalid code.

As Joshua said, you need to investigate how APIENTRY is defined.

Chris
Mark Brethen
2018-11-13 17:52:11 UTC
Permalink
APIENTRY is defined in GL3.h. Snippet below,

/* Function declaration macros - to move into glplatform.h */

#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif


#if defined(__APPLE__)
#define GL3_PROTOTYPES
#endif

#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif

/* Base GL types */
#include <OpenGL/gltypes.h>

#ifdef __cplusplus
extern "C" {
#endif


But the source only had these includes:

#include <GL/gl.h>
#include <GL/glu.h>

which I patched with OpenGL.

From GL3.h:

* gl3.h is supposed to only include APIs in a OpenGL 3.1 (without
* GL_ARB_compatibility) or OpenGL 3.2 or later core profile
* implementation, as well as interfaces for newer ARB extensions which
* can be supported by the core profile. It does not, and never will
* include functionality removed from the core profile, such as
* fixed-function vertex and fragment processing.
*
* Implementations of OpenGL 3.1 supporting the optional
* GL_ARB_compatibility extension continue to provide that functionality,
* as do implementations of the OpenGL 3.2+ compatibility profiles, and
* source code requiring it should use the traditional <GL/gl.h> and
* <GL/glext.h> headers instead of <GL3/gl3.h>.
*
* It is not possible to #include both <GL3/gl3.h> and either of
* <GL/gl.h> or <GL/glext.h> in the same source file.

Do I need to patch the source and replace the GL includes with GL3?


Mark Brethen
Post by Chris Jones
Post by Mark Brethen
Perhaps a semicolon is needed? i.e.
int APIENTRY;
glutExtensionSupported(const char *extension)
nope, that is definitely invalid code.
As Joshua said, you need to investigate how APIENTRY is defined.
Chris
Mark Brethen
2018-11-13 21:27:40 UTC
Permalink
What are the differences between the gl/glu libs in /opt/X11and the OpenGL framework? I was successful in building calculix-cgx using /opt/X11 however the graphics are not displayed correctly in XQuartz.


Mark Brethen
Post by Mark Brethen
APIENTRY is defined in GL3.h. Snippet below,
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#if defined(__APPLE__)
#define GL3_PROTOTYPES
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/* Base GL types */
#include <OpenGL/gltypes.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <GL/gl.h>
#include <GL/glu.h>
which I patched with OpenGL.
* gl3.h is supposed to only include APIs in a OpenGL 3.1 (without
* GL_ARB_compatibility) or OpenGL 3.2 or later core profile
* implementation, as well as interfaces for newer ARB extensions which
* can be supported by the core profile. It does not, and never will
* include functionality removed from the core profile, such as
* fixed-function vertex and fragment processing.
*
* Implementations of OpenGL 3.1 supporting the optional
* GL_ARB_compatibility extension continue to provide that functionality,
* as do implementations of the OpenGL 3.2+ compatibility profiles, and
* source code requiring it should use the traditional <GL/gl.h> and
* <GL/glext.h> headers instead of <GL3/gl3.h>.
*
* It is not possible to #include both <GL3/gl3.h> and either of
* <GL/gl.h> or <GL/glext.h> in the same source file.
Do I need to patch the source and replace the GL includes with GL3?
Mark Brethen
Post by Chris Jones
Post by Mark Brethen
Perhaps a semicolon is needed? i.e.
int APIENTRY;
glutExtensionSupported(const char *extension)
nope, that is definitely invalid code.
As Joshua said, you need to investigate how APIENTRY is defined.
Chris
Loading...