storage class specified?

Programming, for all ages and all languages.
Post Reply
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

storage class specified?

Post 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!
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

I'm pretty stumped by this. Are you sure you can declare a class "extern C"?
Every good solution is obvious once you've found it.
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

what else could i declare it as to get a class in a DLL? i'm confused by c++ :oops:
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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.
User avatar
B.E
Member
Member
Posts: 275
Joined: Sat Oct 21, 2006 5:29 pm
Location: Brisbane Australia
Contact:

Post 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
{ 
...
};
Image
Microsoft: "let everyone run after us. We'll just INNOV~1"
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post 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!
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post 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.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post 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? :)
Last edited by Alboin on Tue May 08, 2007 8:50 pm, edited 1 time in total.
C8H10N4O2 | #446691 | Trust the nodes.
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post 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!
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post 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
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post 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)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post 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.
Post Reply