Public Group

# error: request for member ... which is non-class type XGEngine::XGImage*'

This topic is 5400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello A lil while a go, i posted something about loading the pixels for glDrawPixels. So i got a source code from an engine to load it(XG-Engine). No i finally got some time to start coding again. So i created some variables from the type: XGImage The struct XGImage looks like this:
struct XGImage
{
int Width, Height, Depth;
byte *Data;
};
So after loading the pixels, i want to draw them with the following line(ImageLoad is a variable that i created):
 glDrawPixels(&ImageLoad.Width, &ImageLoad.Height, GL_RGBA, GL_UNSIGNED_BYTE, ImageLoad->Data);
But it gives the following errors:
Quote:
 teacherkiller.cpp:81: error: request for member Width' in ImageLoad', which is of non-class type XGEngine::XGImage*' teacherkiller.cpp:81: error: request for member Height' in ImageLoad', which is of non-class type XGEngine::XGImage*'
So can somebody tell me what i did wrong? Thanx Hylke

##### Share on other sites
you declared ImageLoad as a pointer to a XGEngine::XGImage so you have to use the arrow operator:

##### Share on other sites
From ImageLoad->Data - and from the error string as well - it appear that ImageLoad is a pointer. Therefore, you should do

glDrawPixels(&(ImageLoad->Width), &(ImageLoad->Height), GL_RGBA, GL_UNSIGNED_BYTE, ImageLoad->Data);

Bang. Tooooooo sloooooooooow :P

HTH,

##### Share on other sites
Thanx
But now it says:
Quote:
 /tmp/ccD09iUJ.o(.text+0x38a): In function Load()':/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:79: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccD09iUJ.o(.text+0x49e):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:84: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccD09iUJ.o(.text+0x539):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:85: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccD09iUJ.o(.text+0x5d4):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:86: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccD09iUJ.o(.text+0x66f):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:87: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccD09iUJ.o(.text+0x70a):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:88: more undefined references to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)' followcollect2: ld returned 1 exit status

Line 79:
  BMPImage::LoadImage("Data/Load.dat", ImageLoad);

XGImage *ImageLoad;

No body?

##### Share on other sites
Just make it

and pass it to the load function like this:

and just out of curiosity, what is the .dat file all about? Did you save a .bmp file with a .dat extension or something?

Anyways, I didn't give you the texture manager (which is what checks the extensions to ensure they're valid), so if it is a valid bmp file, the extension shouldn't matter anyways.

Good luck with it.

EDIT: Also note that I didn't give you the whole engine just a couple of files from the engine. The way I have the includes set up for the bmp loader is through my texture manager, so you may have some issues with the file not being included in the proper files. Just make sure you go through all the files where you have BMPImage:: and make sure #include "BMP.h" is included properly.

##### Share on other sites
I just changed my sourcecode(replaced the ->s with a ., and removed the *s).
All my errors:
Quote:
 In file included from teacherkiller.h:28, from teacherkiller.cpp:21:bmp.h:23: warning: malformed '#pragma pack(push[, id], )' - ignoredbmp.h:54: warning: #pragma pack (pop) encountered without matching #pragma pack (push, )/tmp/ccZz4IAY.o(.text+0x389): In function Load()':/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:79: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccZz4IAY.o(.text+0x497):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:84: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccZz4IAY.o(.text+0x531):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:85: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccZz4IAY.o(.text+0x5cb):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:86: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccZz4IAY.o(.text+0x665):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:87: undefined reference to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)'/tmp/ccZz4IAY.o(.text+0x6ff):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:88: more undefined references to XGEngine::BMPImage::LoadImage(std::basic_string, std::allocator >, XGEngine::XGImage*)' followcollect2: ld returned 1 exit status

And the .dat files are .bmp files, but i renamed it to .dat
I include a header file, and that header file includes bmp.h and has using namespace XGEngine;.

Anybody?

##### Share on other sites
Quote:
 Original post by Anonymous PosterNo body?

As the AP said, it looks like you have no body to your LoadImage member function. Either you never defined it or, perhaps more likely, you defined it in a cpp file but labeled it as "inline" which will make it not have linking information. If that's the case, either move the inline function to the header file or remove the word inline and keep it in a cpp file. Either that or you have it inline but aren't including the file that has the definition.

• 21
• 13
• 9
• 17
• 13