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

Started by
8 comments, last by Polymorphic OOP 19 years, 6 months ago
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
tutorials, downloads, flash and moremorbus.vze.com
Advertisement
you declared ImageLoad as a pointer to a XGEngine::XGImage so you have to use the arrow operator:

ImageLoad->Width instead of ImageLoad.Width
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,
ImageLoad->Width
ImageLoad->Height

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

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<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccD09iUJ.o(.text+0x49e):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:84: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccD09iUJ.o(.text+0x539):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:85: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccD09iUJ.o(.text+0x5d4):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:86: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccD09iUJ.o(.text+0x66f):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:87: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, 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<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)' follow
collect2: ld returned 1 exit status

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

ImageLoad:
XGImage *ImageLoad;
tutorials, downloads, flash and moremorbus.vze.com
No body?
Just make it

XGImage ImageLoad

and pass it to the load function like this:

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

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.
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], <n>)' - ignored
bmp.h:54: warning: #pragma pack (pop) encountered without matching #pragma pack
(push, <n>)
/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<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccZz4IAY.o(.text+0x497):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:84: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccZz4IAY.o(.text+0x531):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:85: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccZz4IAY.o(.text+0x5cb):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:86: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)'
/tmp/ccZz4IAY.o(.text+0x665):/home/hylke/Desktop/Teacher Killer/teacherkiller.cpp:87: undefined reference to `XGEngine::BMPImage::LoadImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, 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<char, std::char_traits<char>, std::allocator<char> >, XGEngine::XGImage*)' follow
collect2: 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;.
tutorials, downloads, flash and moremorbus.vze.com
Anybody?
tutorials, downloads, flash and moremorbus.vze.com
Quote:Original post by Anonymous Poster
No 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.

This topic is closed to new replies.

Advertisement