Error: _ defined as a function returning a function?

This is a discussion on Error: _ defined as a function returning a function? within the C Programming forums, part of the General Programming Boards category; I'm trying to compile this library. Recently, i came across the following errors and have no clue what they mean: ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    15

    Error: _ defined as a function returning a function?

    I'm trying to compile this library. Recently, i came across the following errors and have no clue what they mean:

    Code:
    Compiling: ..\..\tests\conform\test-actor-invariants.c
    In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl.h:32,
                     from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/clutter/clutter-fixed.h:33,
                     from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/clutter/clutter-color.h:34,
                     from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/clutter/clutter-actor.h:36,
                     from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/clutter/clutter.h:33,
                     from C:\Prog\clutter-0.9.8\tests\conform\test-actor-invariants.c:4:
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:785: error: syntax error before '*' token
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:786: error: `GLhandleARB' declared as function returning a function
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:790: error: `COGL_PFNGLCREATESHADEROBJECTARBPROC' declared as function returning a function
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:796: error: syntax error before '*' token
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:819: error: syntax error before '*' token
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:830: error: syntax error before "GLcharARB"
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:868: error: syntax error before "GLsizeiptr"
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/cogl/cogl-defines-GL.h:875: error: syntax error before "GLintptr"

    Part of the relevant (I think) code of the include file is as follows (define then lines 784-797):
    Code:
    /* Extension function prototypes */
    
    #ifndef APIENTRY
    #define APIENTRY
    #endif
    
    #ifndef APIENTRYP
    #define APIENTRYP APIENTRY *
    #endif
    ///....way down later
    
    typedef GLhandleARB
      (APIENTRYP             COGL_PFNGLCREATEPROGRAMOBJECTARBPROC)
      (void);
    
    typedef GLhandleARB
      (APIENTRYP             COGL_PFNGLCREATESHADEROBJECTARBPROC)
      (GLenum                shaderType);
    
    typedef void
      (APIENTRYP             COGL_PFNGLSHADERSOURCEARBPROC)
      (GLhandleARB           shaderObj,
       GLsizei               count,
       const GLcharARB*     *string,
       const GLint          *length);
    I truly don't know what these errors could mean, because in the first case i thought COGL_PFNGLCREATEPROGRAMOBJECTARBPROC was simply being defined as a pointer to a function which returns GLhandleARB and takes those parameters. Thus, it must be something else,, i think
    Please help!
    Attached Files Attached Files

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    >> I truly don't know what these errors could mean, because in the first case i thought COGL_PFNGLCREATEPROGRAMOBJECTARBPROC was simply being defined as a pointer to a function which returns GLhandleARB and takes those parameters. Thus, it must be something else,, i think

    It appears that the problem is that GLhandleARB isn't defined anywhere. I looked through the file you posted as well as glib.h, GL.H, and GLExt.H, so I'm assuming you're missing a header file inclusion (which probably should have been included from cogl-defines-gl.h, of course).
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  3. #3
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Code:
    COGL_PFNGLCREATESHADEROBJECTARBPROC
    Wow. I would say these identifiers are in serious need of renaming... that takes a solid 5 seconds to break apart.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  4. #4
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    That's common in opengl. sadly.

    Why not glCreateShaderObjectARBProc?

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    15
    Thx! You were exactly right. I had to update glext.h. I finally got it built! Woopee! Now, i tried the newer version, 0.9.8. I really have got to learn how to debug these sort-of cryptic error messages.
    This one was as follows.

    Code:
    Compiling: ..\..\clutter\cogl\common\cogl-matrix.c
    C:\Prog\clutter-0.9.8\clutter\cogl\common\cogl-matrix.c: In function `cogl_matrix_ortho':
    C:\Prog\clutter-0.9.8\clutter\cogl\common\cogl-matrix.c:221: error: parameter name omitted
    C:\Prog\clutter-0.9.8\clutter\cogl\common\cogl-matrix.c:222: error: parameter name omitted
    C:\Prog\clutter-0.9.8\clutter\cogl\common\cogl-matrix.c:241: error: syntax error before ')' token
    C:\Prog\clutter-0.9.8\clutter\cogl\common\cogl-matrix.c:247: error: syntax error before ')' token
    C:\Prog\clutter-0.9.8\clutter\cogl\common\cogl-matrix.c:247: error: syntax error before ')' token
    The relevant function is:

    Code:
    void
    cogl_matrix_ortho (CoglMatrix *matrix,
                       float left,
                       float right,
                       float bottom,
                       float top,
                       float near,
                       float far)
    {
      CoglMatrix ortho;
    
      /* column 0 */
      ortho.xx = 2.0 / (right - left);
      ortho.yx = 0.0;
      ortho.zx = 0.0;
      ortho.wx = 0.0;
    
      /* column 1 */
      ortho.xy = 0.0;
      ortho.yy = 2.0 / (top - bottom);
      ortho.zy = 0.0;
      ortho.wy = 0.0;
    
      /* column 2 */
      ortho.xz = 0.0;
      ortho.yz = 0.0;
      ortho.zz = -2.0 / (far - near);
      ortho.wz = 0.0;
    
      /* column 3 */
      ortho.xw = -(right + left) / (right - left);
      ortho.yw = -(top + bottom) / (top - bottom);
      ortho.zw = -(far + near) / (far - near);
      ortho.ww = 1.0;
    
      cogl_matrix_multiply (matrix, matrix, &ortho);
    }
    The only thing i can think of is that if somehow CoglMatrix was defined as #define CoglMatrix , or something else which broke the function definition. Not so, though. In cogl-matrix.h, CoglMatrix is defined as

    Code:
    typedef struct _CoglMatrix      CoglMatrix;
    and then...
    Code:
    struct _CoglMatrix
    {
        /*< private >*/
    
        /* column 0 */
        float xx;
        float yx;
        float zx;
        float wx;
    //......
    Attached Files Attached Files

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    >> This one was as follows.

    Windows header files are rife with annoying macros that don't follow the standard uppercase convention, including 'near' and 'far'. You can either #undef these macros, rename the cogl_matrix_ortho parameters, or just ensure that windows.h is included *after* all others. Another useful tactic is to put together a separate header file to be included instead of windows.h (eg: clean_windows.h) that includes windows.h internally and #undef's all of those problematic macros.
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  7. #7
    Registered User
    Join Date
    Jul 2009
    Posts
    15
    But what does the error message mean??

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    >> But what does the error message mean??

    The compiler is just confused, so the error message is really unimportant. Windows defines them as empty macros, eg:

    #define far

    So after the preprocessor expands the macro, all the compiler sees is:

    Code:
    void
    cogl_matrix_ortho (CoglMatrix *matrix,
                       float left,
                       float right,
                       float bottom,
                       float top,
                       float,
                       float)
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  9. #9
    Registered User
    Join Date
    Jul 2009
    Posts
    15
    near and far are defined as empty macros? weird... any other headers which contain these weird macros that i should know about?

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,955
    Quote Originally Posted by Jardon
    near and far are defined as empty macros? weird...
    Weird indeed, but my guess is that it is so as to make legacy code that involves the concept of near and far pointers to be compilable.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    Jul 2009
    Posts
    15
    I would just quickly confirm the interpretation of this error message. I'm guessing it means that it either didn't link to a lib file or the lib file doesn't contain the function. The c file which had the functions compiled fine and produced the o files. So


    Linking dynamic library: bin\Debug\clutter_d.dll
    obj\Debug\clutter\clutter-actor.o: In function `clutter_actor_apply_relative_transform_to_point':
    C:/Prog/clutter-0.9.8/clutter/clutter-actor.c:1824: undefined reference to `cogl_get_viewport'
    obj\Debug\clutter\clutter-actor.o: In function `clutter_actor_apply_transform_to_point':
    C:/Prog/clutter-0.9.8/clutter/clutter-actor.c:1877: undefined reference to `cogl_get_viewport'
    //and alot of other similar errors

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    >> I'm guessing it means that it either didn't link to a lib file or the lib file doesn't contain the function.

    Right. You need to find where the symbol cogl_get_viewport resides and link appropriately (if it's in a source file you'll need to compile it and link to the object file, obviously).
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  13. #13
    Registered User
    Join Date
    Jul 2009
    Posts
    15
    K. So i'm almost there. I just have another linking error. This time, it can't find
    glClientActiveTexture. Using my mesa gl build, i replaced the system32 dll with its opengl32.dll and linked the linker to the opengl32.lib. still got an error. Using dumpbin to view exports, i found that there were similar exported functions, namely
    _glClientActiveTexture@4
    _glClientActiveTextureARB@4 (i'm guessing the _ aren't actually in the exported function name?)
    I can't use these, because its not in the .h file. So i guess i'm asking where can i find an opengl32 binary which will have this function? And how do i read these exports, are these
    names exactly the names of the exported function?



    Error:

    Linking dynamic library: bin\Debug\clutter_d.dll
    Creating library file: bin\Debug\libclutter_d.a
    obj\Debug\clutter\cogl\common\cogl.o: In function `cogl_begin_gl':
    C:/Prog/clutter-0.9.8/clutter/cogl/common/cogl.c:831: undefined reference to `glClientActiveTexture'
    obj\Debug\clutter\cogl\gl\cogl-primitives.o: In function `cogl_add_path_to_stencil_buffer':
    C:/Prog/clutter-0.9.8/clutter/cogl/gl/cogl-primitives.c:175: undefined reference to `glClientActiveTexture'
    collect2: ld returned 1 exit status

  14. #14
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Visual Studio prefixes exported symbols with an underscore, so that's where it comes from. The openGL documentation states that glClientActiveTexture is supported in versions 1.3 or greater. What version are you using?

  15. #15
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    Interesting, I looked through all of my OGL lib/dll files and couldn't find a single one with a reference to those functions. I looked through the gl.h header file and noticed this though:

    Code:
    /* Under Windows, we do not define OpenGL 1.2 & 1.3 functionality, since
       it is treated as extensions (defined in glext.h) */
    glClientActiveTexture is a 1.3 function, so it may not even be available on your system. Your best bet at this point would probably be to visit the OGL forums.
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Problem in returning value from the dll exported function
    By dattaforit in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2006, 03:30 AM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. returning pointers from a function
    By curlious in forum C++ Programming
    Replies: 2
    Last Post: 12-28-2003, 10:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21