Thread: Error: _ defined as a function returning a function?

  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!

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> 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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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;
    //......

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> 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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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,708
    >> 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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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
    28,413
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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,708
    >> 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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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,268
    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,708
    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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

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, 04:30 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. returning pointers from a function
    By curlious in forum C++ Programming
    Replies: 2
    Last Post: 12-28-2003, 11:37 PM