Page 1 of 1

storage class specified?

Posted: Tue May 08, 2007 8:22 am
by GLneo
I'm going to start working on my little 3d game engine in c++, but I have a problem ( one problem is I dont know c++ too much ) when I compile I get this:

Code: Select all

22 C:\Dev-Cpp\Engine\Func\Engine.h storage class specified for field `load3ds' 
about this file (engine.h):

Code: Select all

#ifndef _ENGINE_H_
#define _ENGINE_H_

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

extern "C" __declspec(dllexport) void make_light (int name, float pos_x, float pos_y, float pos_z, float color_r, float color_g, float color_b, float alf);
extern "C" __declspec(dllexport) void change_light (int name, float pos_x, float pos_y, float pos_z, float color_r, float color_g, float color_b, float alf);
extern "C" __declspec(dllexport) void material (float amb_r, float amb_g, float amb_b, float met_r,  float met_g,float met_b);
extern "C" __declspec(dllexport) void textureffgLoader (char * name, int id);
extern "C" __declspec(dllexport) void texturetgaLoader(char * name, int id);
extern "C" __declspec(dllexport) void texturebmpLoader(char * name, int id);

extern "C" __declspec(dllexport) class OBJECT
{ 
    public:
        
         OBJECT();
         ~OBJECT();
         void load3ds(char *name); //<------------ error!
         void loadobj(char *name);
         void loadmd2(char *name);
         bool display(int frame);
         void kill();
         int frames();
         int vertexs();
         int triangles();

    private:
        
        typedef struct{
            float x,y,z;
            float nx, ny, nz;
            bool norm;
        }vertexx;

        typedef struct{
            int a,b,c;
        }trianglex;

        typedef struct{
            float u,v;
        }texcoordx;

        typedef struct 
        {
	        char name[20];
	        int vert_num;
            int poly_num;
            int fram_num;
            vertexx vertex[5000];
            trianglex triangle[5000];
            texcoordx texcoord[5000];
            int tex;
        }objects, *objectsp;
        
        objects object;
        
        typedef struct 
        {
            int magic;
            int version;
            int skinWidth;
            int skinHeight;
            int frameSize;
            int numSkins;
            int numVertices;
            int numTexCoords;
            int numTriangles;
            int numGlCommands;
            int numFrames;
            int offsetSkins;
            int offsetTexCoords;
            int offsetTriangles;
            int offsetFrames;
            int offsetGlCommands;
            int offsetEnd;
        }Md2Header;

        Md2Header Md21;

        typedef struct 
        {
            char skinName[64];
        }ASkin;

        typedef struct 
        {
            short u, v;
        }ATexCoord;

        typedef struct 
        {
            float vertex[3];
            float normal[3];
        }AVertice;

        typedef struct 
        {
            short vertexIndex[3];
            short texIndex[3];
        }ATriangle;

        typedef struct 
        {
            unsigned char vertex[3];
            unsigned char lightNormalIndex;
        }AVert;

        typedef struct 
        {
            float scale[3];
            float translate[3];
            char strFrameName[16];
            AVertice *Vertsp;
        }AFrame;
        
        ASkin *Skinsp;
        ATexCoord *TexCoordsp;
        AFrame *Framesp;
        ATriangle *Trianglesp;
};

int OBJECT::frames() 
{
    return object.fram_num; 
}
int OBJECT::vertexs() 
{
    return object.vert_num;
}
int OBJECT::triangles() 
{
    return object.poly_num;
} 

OBJECT::OBJECT()
{
}

OBJECT::~OBJECT()
{
}    

#endif
I don't know what this means? does anyone know how to fix this?

thx!

Posted: Tue May 08, 2007 8:53 am
by Solar
I'm pretty stumped by this. Are you sure you can declare a class "extern C"?

Posted: Tue May 08, 2007 9:07 am
by GLneo
what else could i declare it as to get a class in a DLL? i'm confused by c++ :oops:

Posted: Tue May 08, 2007 10:37 am
by Tyler
Depends on the Specific C++ Compiler how you do it, but it is not by using extern "C", that definetly cannot be used on a class. I am afraid for the specifics you will have to look at the manual for your compiler. Logically, a completely C++ strucutre cannot be exported as C compatible.

Posted: Tue May 08, 2007 6:34 pm
by B.E
With a simple google search it came up with this.
So try something like this

Code: Select all

class __declspec(dllexport)  OBJECT
{ 
...
};

Posted: Tue May 08, 2007 7:44 pm
by GLneo
OK, i tried to use : "class __declspec(dllexport) OBJECT " but i get the same error, I'm really stumped because I think I used the same code on same compiler on a different computer??? I have tried different compilers, could i compile this DLL with cygwin?

thx!

Posted: Tue May 08, 2007 8:38 pm
by Kevin McGuire
GLNeo wrote: I'm really stumped because I think I used the same code on same compiler on a different computer???
One out of three leaves: You and the Compiler.
GLNeo wrote: I have tried different compilers.....
What compilers have you tried?
GLNeo wrote: ....could i compile this DLL with cygwin?
Try it and see. If you did that, you'd (a) learn the answer, and (b) stop wasting my time thinking about how to install cygwin and try it for you.

I apologize for my behavior it's just that my crystal ball is at the shop for repairs right now.

Posted: Tue May 08, 2007 8:49 pm
by Alboin
Kevin McGuire wrote:I apologize for my behavior it's just that my crystal ball is at the shop for repairs right now.
What, you're too good for /dev/random? :)

Posted: Tue May 08, 2007 8:49 pm
by GLneo
i was just asking if cygwin could build DLL's or if that is a mingw only, sorry to hear about your crystal ball, when its fixed tell me my future :roll:

if possible how do you tell cygwin to compile DLL's?

thx!

Posted: Tue May 08, 2007 9:22 pm
by Kevin McGuire
Solar, was right about removing the decoration with extern "C".
http://www.codeguru.com/cpp/w-p/dll/imp ... c123/#more

Seventh item in the list.
http://www.google.com/search?hl=en&q=ex ... tnG=Search

Posted: Tue May 08, 2007 10:41 pm
by GLneo
well magically it fixed itself!, I guess that means Kevin McGuire's magic crystal ball is fixed and he cured my code, seriously i just recompiled because i had nothing better to do and... BAM compilation!

thx for all the help :P 8)

Posted: Wed May 09, 2007 12:11 pm
by Candy
GLneo wrote:well magically it fixed itself!, I guess that means Kevin McGuire's magic crystal ball is fixed and he cured my code, seriously i just recompiled because i had nothing better to do and... BAM compilation!
If you didn't fix the problem then you didn't fix the problem.