Zeige Ergebnis 4.621 bis 4.650 von 10174
C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Either that, or the libs are in the wrong order. Edit: Too late....
-
05-20-2007, 06:48 AM #4621QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Either that, or the libs are in the wrong order.
Edit: Too late.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-20-2007, 06:51 AM #4622QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
@hello: These two implementations are equivalent:
Code:char array[5][10]; char x = array[4][7];
Now think how you would properly copy an array. Also, as a note, you don't have to copy the array if you just want to access the elements differently. In that case you could just create a pointer to the structure.Code:char array[5*10]; char x = array[4*10 + 7];
Also, a char* array[x][y] is the same (in regards to memory usage and binary contents) as an int array[x][y], just that every int is actually a memory address (a pointer).Code:char array[x][y]; char* array2 = array; array2[x*y-1] = 5; // same as array[x-1][y-1] = 5;
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
05-20-2007, 06:51 AM #4623QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It exactly the same. I am more concerned on why you would want to do this as there will be problems such as non NULL terminated strings which can lead to severe buffer overruns.
Zitat von hallo007
-= Double Post =-
Eg
Code:char aString[16] "Hello World"; char aString2[4][4]; int k = 0; for( int i = 0; i < 4; i += 1 ) { for( int j = 0; j < 4; j += 1, k +=1 ) { aString2[i][j] = aString[k]; } } printf( "%s", aString2[0] ); // Buffer overrun, C string not NULL terminated // Undefined behaviour. If you are lucky, it will just print out "Hello World"Geändert von yaustar (05-20-2007 um 07:00 AM Uhr) Grund: Automerged Doublepost
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-20-2007, 07:45 AM #4624Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
this works fine for me:) , thnx;)Code:#include <stdio.h> int main() { char *aString[4] = {"Hello World" , "nothing" , "nothing" , "nothing"}; char *aString2[2][2]; int k = 0; for( int i = 0; i < 4; i += 1 ) { for( int j = 0; j < 4; j += 1, k +=1 ) { aString2[i][j] = aString[k]; } } printf( "%s", aString2[0][0] ); // Buffer overrun, C string not NULL terminated // Undefined behaviour. If you are lucky, it will just print out "Hello World" getchar(); }
-
05-20-2007, 07:59 AM #4625QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Oh god. ... I just don't know what to say.....
Zitat von hallo007
Remind me not to use any of your flashers.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-20-2007, 08:10 AM #4626Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
uh? whats wrong ?
-
05-20-2007, 08:13 AM #4627It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It's completely unsafe.
http://en.wikipedia.org/wiki/Buffer_overflow - Read up.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-20-2007, 08:17 AM #4628Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
and what has that to do with my flasher :/ if i am asking something here , then i dindt tried it yet :/
-
05-20-2007, 08:19 AM #4629It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Unsafe programming can lead to a myriad of problems, including writing the wrong data, writing too much data, security vulnerabilities, etc. If one of these problems affects a flasher...goodbye PSP!
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-20-2007, 08:22 AM #4630QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
If the quality of the code that you have shown here is the same as your flasher, then I dread to see what possible bugs exist in your flasher.
Either way, the code that you have shown in that last snippet doesn't give me any confidence that any of your programs are 'safe'. This isn't much of a problem if it was a game or an application, but since you mostly write flashers, this kind of error can lead to a PSP brick.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-20-2007, 09:04 AM #4631Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
but i dindt use it in the app , but can you show mee how to mkae it safe?
-
05-20-2007, 09:41 AM #4632words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
He never said you did use it in your flashers. He's saying that the quality of that last snippet you posted was unsafe/horrible, leading him to believe all of your code quality is unsafe/horrible, even the flashers you write.
As for making it safe, you need some memory allocations, buffer overrun safeties (strncpy, strncat, snprintf,etc..) and seeing as how your using C++ (int i = 0 in for loop) Id use some of it's abilities
Now, im not 100% sure what it is you want to happen, as running your code spits out Hello World, no nothing, nothing, etc defeating the purpose of having the nothing's. This here spits out 'nothingnothing' AKA the last element in aString array because your 2 for loops (it sets aString2[0 & 1] to all 4 elements of aString array but over writes the last) Please elaborate on what you want it to do if this isnt it.Code:#include <iostream> int main() { const NUM_OF_ASTRING = 4, NUM_OF_ASTRING2 = 2; const std::string aString[NUM_OF_ASTRING] = { "Hello World" , "nothing" , "nothing" , "anothing" }; std::string aString2[NUM_OF_ASTRING2]; for( int i = 0; i < NUM_OF_ASTRING2; i++ ) for( int j = 0; j < NUM_OF_ASTRING; j++ ) aString2[i] = aString[j]; std::cout << aString2[0] << aString2[1] << std::endl; system("PAUSE"); // you used 'getchar()' some im assuming your on PC return 0; }
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
05-20-2007, 10:47 AM #4633Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
I dont really understand that so i just going to explain for what i am goign to use it.
I call a function that gets all file paths in a folder
it will be stored to
char *filePaths[200];
now I want to use it and blit it to screen like a desktop
so structured in
X-as : 15 files
y-as : 10 files
(so 150 files)
to make the code a bit more clearly and easy,I will store it in something like
char *paths[15][10];
-= Double Post =-
nvm , i just had the change to chekc your cod
this is exactly what I need
Code:#include <iostream> int main() { const int NUM_OF_ASTRING = 4, NUM_OF_ASTRING2 = 2; int z = 0; const std::string aString[NUM_OF_ASTRING] = { "Hello World" , "nothing" , "nothing" , "anothing" }; std::string aString2[2][2]; for( int i = 0; i < 2; i++ ) for( int j = 0; j < 2; j++ ) { aString2[i][j] = aString[z]; z++; } std::cout << aString2[0][0] << " " << aString2[0][1] << std::endl; std::cout << aString2[1][0] << " " << aString2[1][1] << std::endl; system("PAUSE"); // you used 'getchar()' some im assuming your on PC return 0; }Geändert von hallo007 (05-20-2007 um 12:42 PM Uhr) Grund: Automerged Doublepost
-
05-20-2007, 01:57 PM #4634QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Hi guys. I posted a while back and got no responce to this.
why doesn't this run?
It does compile but whenever i try to run it, it just freezes up. (not a crash, a freeze)
thanks for your help.
makefile:Code:#include <pspdisplay.h> #include <stdlib.h> #include <pspctrl.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspgu.h> #include <png.h> #include <stdio.h> #include <time.h> #include <psppower.h> #include <pspaudio.h> #include <pspaudiolib.h> #include "graphics.h" #include "mp3player.h" #define true 1 #define false 0 PSP_MODULE_INFO("DotsC v0.0.3 Alpha", 0, 0, 3); /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } char *path[13] = { "Player.png", //0 "Background.png", //1 "Spot.png", //2 "zero.png", //3 "one.png", //4 "two.png", //5 "three.png", //6 "four.png", //7 "five.png", //8 "six.png", //9 "seven.png", //10 "eight.png", //11 "nine.png"}; //12 int main() { srand(time(NULL)); pspDebugScreenInit(); initGraphics(); int spotx = rand()%(465); int spoty = rand()%(257); int x=0; int y=0; int Scoreo=0; int Scoret=0; int Scoreh=0; int Scoreth=0; SceCtrlData pad; Image* images[14]; int i; for(i = 0; i > 13; i++) { images[i] = loadImage(path[i]); } while (1) { sceCtrlReadBufferPositive(&pad, 1); blitAlphaImageToScreen(0 ,0 ,32 , 32, images[0], x, y); blitAlphaImageToScreen(0 ,0 ,480 , 272, images[1], 0, 0); blitAlphaImageToScreen(0 ,0 ,16 , 16, images[2], spotx, spoty); blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoreo + 3], 50, 1); blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoret + 3], 35, 1); blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreh + 3], 20, 1); blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreth + 3], 5, 1); if (x + 32 > spotx && x < spotx + 16 && y + 32 > spoty && y < spoty + 16) { Scoreo = Scoreo + 2; spotx = rand()%(465); spoty = rand()%(257); } if (Scoreo == 10) { Scoreo = 0; Scoret++; } if (Scoret == 10) { Scoret = 0; Scoreh++; } if (Scoreh == 10) { Scoreh = 0; Scoreth++; } if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x > 448) { x = 448; } if (y > 240) { y = 240; } if(pad.Buttons & PSP_CTRL_RIGHT) { x += 5; } else if(pad.Buttons & PSP_CTRL_LEFT) { x -= 5; } else if(pad.Buttons & PSP_CTRL_UP) { y -= 5; } else if(pad.Buttons & PSP_CTRL_DOWN) { y += 5; } else if(pad.Buttons & PSP_CTRL_START) { sceKernelExitGame(); } flipScreen(); } sceKernelSleepThread(); return 0; }
Code:TARGET = Square_Game OBJS = main.o graphics.o framebuffer.o mp3player.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = LIBS = -lpspgu -lpng -lz -lm -lpsprtc -lmad -lpspaudiolib -lpspaudio -lpsppower LDFLAGS = EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = DotsC v0.0.3 Alpha PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak
-
05-20-2007, 02:04 PM #4635QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- France
- Beiträge
- 753
- Points
- 5.784
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Shouldn't it be i < 13 ?Code:for(i = 0; i > 13; i++) { images[i] = loadImage(path[i]); }
++ B.if I make mistakes in english, feel free to correct me or else i won't progress :D .
-
05-20-2007, 02:25 PM #4636QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
heh....
thats funny.
that guy tried to clean up my code, but he actually screwed it up... :)
well, thanks to both of you anyway.
yeah! it works!
thanks a lot.
my player wont move for some reason....
my start button exit works....
must be something with the graphics...
dont i need a sceWaitVblankStart() in there somewhere?Geändert von Nicko01 (05-20-2007 um 02:39 PM Uhr)
-
05-20-2007, 02:48 PM #4637QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
not sure, by all means it should, try loading any thing that has to move/sprites, normal way like,
Image* playerimg = loadImage("./sprites/player.png");
or something like that, im sure theres a work around for your problem so just wait till someone comes up with something better.....Zeegyboogydo
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
05-20-2007, 03:15 PM #4638QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Homebrewland, CA
- Beiträge
- 191
- Points
- 4.295
- Level
- 41
- Downloads
- 0
- Uploads
- 0
This is what I have, try it out. BTW your indentation is horrible..
Code:#include <pspdisplay.h> #include <stdlib.h> #include <pspctrl.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspgu.h> #include <png.h> #include <stdio.h> #include <time.h> #include <psppower.h> #include <pspaudio.h> #include <pspaudiolib.h> #include "graphics.h" #include "mp3player.h" #define true 1 #define false 0 PSP_MODULE_INFO("DotsC v0.0.3 Alpha", 0, 1, 1); /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } char *path[13] = { "Player.png", //0 "Background.png", //1 "Spot.png", //2 "zero.png", //3 "one.png", //4 "two.png", //5 "three.png", //6 "four.png", //7 "five.png", //8 "six.png", //9 "seven.png", //10 "eight.png", //11 "nine.png"}; //12 int main() { srand(time(NULL)); SetupCallbacks(); pspDebugScreenInit(); initGraphics(); int spotx = rand()%(465); int spoty = rand()%(257); int x = 0; int y = 0; int Scoreo = 0; int Scoret = 0; int Scoreh = 0; int Scoreth = 0; SceCtrlData pad; Image* images[14]; int i; for(i = 0; i < 13; i++) { images[i] = loadImage(path[i]); } while(1) { if (x + 32 > spotx && x < spotx + 16 && y + 32 > spoty && y < spoty + 16) { Scoreo = Scoreo + 2; spotx = rand()%(465); spoty = rand()%(257); } if (Scoreo == 10) { Scoreo = 0; Scoret++; } if (Scoret == 10) { Scoret = 0; Scoreh++; } if (Scoreh == 10) { Scoreh = 0; Scoreth++; } if (x < 0){x = 0;} if (y < 0){y = 0;} if (x > 448){x = 448;} if (y > 240){y = 240;} sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_RIGHT){x += 5;} if(pad.Buttons & PSP_CTRL_LEFT){x -= 5;} if(pad.Buttons & PSP_CTRL_UP){y -= 5;} if(pad.Buttons & PSP_CTRL_DOWN){y += 5;} //image loop- I don't know if your character array is correct, didn't look. If if is correct this should work. blitAlphaImageToScreen(0 ,0 ,32 , 32, images[0], x, y); blitAlphaImageToScreen(0 ,0 ,480 , 272, images[1], 0, 0); blitAlphaImageToScreen(0 ,0 ,16 , 16, images[2], spotx, spoty); blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoreo + 3], 50, 1); blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoret + 3], 35, 1); blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreh + 3], 20, 1); blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreth + 3], 5, 1); flipScreen(); } sceKernelSleepThread(); return 0; }
-
05-22-2007, 05:14 AM #4639
I want to load recovery menu from a prx with an eboot. heres my code:
when I run the app this appears on my psp screenCode:#include <pspkernel.h> #include <pspdebug.h> #include <pspdisplay.h> #include <pspsdk.h> #include <string.h> #include <pspctrl.h> #include <stdio.h> #include <stdlib.h> PSP_MODULE_INFO("LAUNCH_RECOV", 0x1000, 1, 1); PSP_MAIN_THREAD_ATTR(0); #define printf pspDebugScreenPrintf int exit_callback(int arg1, int arg2, void *arg) { sceKernelExitGame(); return 0; } void CallbackThread(void *arg) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); } int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", (void*) CallbackThread, 0x11, 0xFA0, 0xa0000000, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } void restart() { sceKernelExitGame(); } SceUID load_module(const char *path, int flags, int type) { SceKernelLMOption option; SceUID mpid; if (type == 0) { mpid = 1; } else { mpid = 2; } memset(&option, 0, sizeof(option)); option.size = sizeof(option); option.mpidtext = mpid; option.mpiddata = mpid; option.position = 0; option.access = 1; return sceKernelLoadModule(path, flags, type > 0 ? &option : NULL); } void *getModuleInfo(void); int main(void) { SceUID modid; SceModule *mod; pspDebugScreenInit(); pspDebugInstallKprintfHandler(NULL); pspDebugInstallErrorHandler(NULL); pspDebugInstallStdoutHandler(pspDebugScreenPrintData); pspSdkInstallNoPlainModuleCheckPatch(); SetupCallbacks(); while (1) { SceCtrlData pad; sceCtrlPeekBufferPositive(&pad, 1); if (pad.Buttons & PSP_CTRL_WLAN_UP){ modid = load_module("ms0:/recovery.prx", 0, 0); } else { sceKernelExitGame(); } sceKernelExitDeleteThread(0); } return 0; }
obviously there is an error loading the prx but i cant see why. please helpCode:stdio.c : stdoutReopen : id=0x00000001 stdio.c : stdoutReopen : id=0x00000002
-
05-22-2007, 07:33 AM #4640Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
since i went over to c++ i have a problem with includes , if the first .o includes a header , it wont be anymore included by the second and it says , undeclarded :-SCode:#ifndef DESKTOP_H #define DESKTOP_H #include <stdlib.h> #include <malloc.h> #include <pspdisplay.h> #include <psputils.h> #include <png.h> #include <pspgu.h> #include <string.h> #include "../main.h" #include "../graphics/graphics.h" #define imageDrawAlpha blitImage #define START 0 #define BALK 1 #define IMAGE_ICON 2 #define EXE_ICON 3 #define FLASH_ICON 4 #define PSPFILE_ICON 5 #define AUDIO_ICON 6 #define UNKNOW_ICON 7 #define THISPSP_ICON 8 #define TEXT_ICON 9 #define FOLDER_ICON 10 int mainMenu(SceSize args, void *argp); #endif
-
05-22-2007, 11:30 AM #4641QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
extern "C" {
#include "_Headers_here_"
}
-
05-22-2007, 11:59 AM #4642Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
That wasnt the problem , i did that in the headers , no i was forgotten to set up some macro's that i always use , nvm
-
05-22-2007, 01:28 PM #4643QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Oh god.
Whenever I compile anything, it will come up with the error:
main.cpp: UNDEFINED REFRENCE OF [variable_name] AT C:/[Location_name].
I searced it, and at the location it spits at me, it shows no reference, and there is no refrence, anyone know what the problem is? (Let me guess...I coded the program wrong?)
EDIT: I tried to compile a hello world, just to make sure, and it gave me the same error...
-
05-22-2007, 01:30 PM #4644QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Post the code.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-22-2007, 01:33 PM #4645
Oh, alow! :ROFL:
Will passing variables as arguments instead of direct arguements add overhead time just like functions do when called? [Donot say -- it's a tenth-tenth of a sec or something a& it doesn't matter] --- IT does for me, that time is so valuable for me...
My assumption is, it doesn't make a difference because even the direct argument as well as a variable reside in some memory location --- which the function has to fetch... Am I right?
------
I am so concerned becz the variable changes every once per function call, in that function a lot of sub functions use this variable....
-
05-22-2007, 01:35 PM #4646QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Zitat von yaustar
Like I said, I used a hello world for a test.Code:#include <pspkernel.h> #include <pspdebug.h> PSP_MODULE_INFO("Test Hello World:, 0, 1, 1); #define printf pspDebugScreenPrintf /* I don't want to post callbacks here, takes to much space up, but they ARE in my code */ int main() { SetupCallbacks(); pspDebugScreenInit(); printf("Test Hello World."); sceKernelSleepThread(); return 0; }
It gives me the error of the refrence of SetupCallbacks();
-
05-22-2007, 01:38 PM #4647QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Show ALL the code ¬¬
Zitat von MrChaos
-= Double Post =-
Depends on a large number of factors.
Zitat von Mr305
Are you passing by pointer?
Are you passing by reference?
Are you passing by value?
What type are the objects being passed?
What do you mean by direct argurements?
Do you have the code in question to post up?Geändert von yaustar (05-22-2007 um 01:40 PM Uhr) Grund: Automerged Doublepost
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-22-2007, 01:42 PM #4648QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Zitat von yaustar
makefileCode:#include <pspkernel.h> #include <pspdebug.h> PSP_MODULE_INFO("Test Hello World", 0, 1, 1); #define printf pspDebugScreenPrintf /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } int main() { SetupCallbacks(); pspDebugScreenInit(); printf("Test Hello World."); sceKernelSleepThread(); return 0; }
Code:TARGET = hello OBJS = main.cpp CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Hello World Test PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak
-
05-22-2007, 01:49 PM #4649QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
1.) PSP_MODULE_INFO("Test Hello World:, 0, 1, 1);
Zitat von MrChaos
See the error?
2.) It gives me the error of the refrence of SetupCallbacks();
Undefined reference to the function SetupCallbacks.
It will give you that error if you remove the callbacks from the program, and try to call a nonexistent function. Just remove SetupCallbacks(); or put the callbacks in.[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
05-22-2007, 01:49 PM #4650QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
yaustar, I tried again, and heres the errors:
/cygdrive/c/DOCU~1/Owner/LOCALS~1/Temp/cc2wayHC.o
.eh_frame+0x11): undefined reference to '__gxx_personality_v0'
Moca: Yeah, I saw that, and fixed it.
Moca: I removed the callbacks and SetupCallbacks();...no help.


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum