Seite 158 von 340 ErsteErste ... 58 108 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 208 258 ... LetzteLetzte
Zeige Ergebnis 4.711 bis 4.740 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; stdio rather defines it, I'd say....

  
  1. #4711
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    stdio rather defines it, I'd say.


    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  2. #4712
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    stdio rather defines it, I'd say.
    *Smacks head against a wall*

  3. #4713
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSPJunkie_
    *Smacks head against a wall*
    *helps*
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  4. #4714
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    ...I'm missing something.

    Did I say something stupid without realizing it again?
    Forgive me, I'm rather tired right now.
    Anyway, I just meant that stdio defines it, but doesn't use it.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  5. #4715
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    since i added the mouse part , it's just crashing
    Code:
    int main(SceSize args, void *argp)
    {
        string desktopFiles[12][24];          //Storage for floople lloopst loopn desktop dlooprectory
        int z = 0;                            //storage for copying strings
        int x = 10;                            //storage for x coordinate
        int y = 10;                            //storage for y coordinate
        int mouseX = 10;
        int mouseY = 10;
        char imageBuffer[20];                 //buffer for image loading
        char *fileListBuffer;                 //buffer for file names
        
        SceCtrlData pad;
        sceCtrlSetSamplingCycle(0);
        sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
        
        
        Image *iconExample = loadImage("data/desktop/icon.PNG");//the icon
        Image *iconFolder  = loadImage("data/desktop/folder.PNG");
        Image *mouse       = loadImage("data/desktop/mouse.PNG");
        string fileBuffer[222];                               //for the filelist
        
        //init the garphics
        initGraphics();
        pspDebugScreenInit();
        pspDebugScreenClear();
        
        //Load screenshot module
        LoadStartModule("data/screenshot.prx");
        
        //loopmages load
        /*for(int loop = 0; loop < sizeof(desktopImages); loop++)
        {
                 snprintf(imageBuffer ,sizeof(imageBuffer) - 1,  "%i.PNG" ,loop);
                 desktopImages[loop] = loadImage(imageBuffer);
                 }*/
                 
        desktopBack = loadImage("data/desktop/wallpaper.PNG");
        /*if(desktopBack < 0) printf("failed to load image\n");
        else  printf("Image loaded\n");*/
        getFileList("ms0:/");  
        while(1)
        {
                  
                //printf("file paths stored\n");
    
                //printf("Stored to new variabel\n");
                blitImage(0,0,desktopBack);
                for(int loop = 0; loop < sizeof(fileList); loop++ )
                {
                      char buffer[10];
                      if(y!=0) y += 10;
                      if(sizeof(fileList[loop]) > 10)
                      {
                                         strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3);
                                         strcat(buffer , "..");
                                         fileBuffer[loop] = buffer;
                                         }
                      else
                      {
                           fileBuffer[loop] = fileList[loop];
                           }
                     // if(isFile(fileList[loop]))
                      //{
                           blitImage(x , y ,iconExample);
                          // }
                     // else
                      //{
                           //blitImage(x , y ,iconFolder);
                           //}    
                      y += 40;    
                      printg(x , y , fileBuffer[loop].c_str() , white);
                
                      if(y > 249)
                      {
                          x += 108;
                          y = 10;
                          } 
                          }  
                      blitImage(mouseX , mouseY , mouse);
                      flipScreen();
                      while(1)
                      {
                              sceCtrlReadBufferPositive(&pad, 1);	 
                              
                              if (pad.Lx < 80) //left
                              {
                                         mouseX -= 10;
                                         if(mouseX<0) mouseX = 460;
                                         break;
                                         }
                              if (pad.Lx > 175) //right
                              {
                                         mouseX += 10; 
                                         if(mouseX > 480) mouseX = 0;
                                         break;
                                         }
    	                      if (pad.Ly > 175) //down
    	                      {
                                         mouseY -= 10;
                                         if(mouseY<0) mouseY = 255;
                                         break;
                                         }
    	                      if (pad.Ly < 80) //up
    	                      {
                                         mouseY += 10;
                                         if(mouseY > 272) mouseY = 0;
                                         break;
                                         }
                              if(pad.Buttons & PSP_CTRL_HOME)
                              {
                                             sceKernelExitGame();
                                             }
                        }
                       
        }//end while
    
       /* for(int loop = 0; loop < 12; loop++ )
             for(int looptwee = 0; looptwee < 24; looptwee++ )
             {
                     getImageToBuffer[loop][looptwee] = getImage(desktopFiles[loop][looptwee].c_str());                         
                     blitImage(x , y ,  getImageToBuffer[loop][looptwee]);
                     x += 20;
                     y += 20;
                     }*/
                  
        flipScreen();
        
        sceKernelSleepThread();
        return 0;
    }
    yes , i know the code is ugly at the moment

  6. #4716
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von youresam
    thats why you #define it after #include'ing it *omg*
    Unless you know the exact order of files that the preprocessor goes through, that is a dangerous assumption to make. It be better (but still horrendous) to use printfSomeElse or:
    Code:
    #ifdef WINDOWS
    #define printfDebugText printf
    #else
    #define printfDebugText pspDebugScreenPrintf
    #endif
    
    int main()
    {
        //.....
        printfDebugText( "Hello World" );
    }
    That would be better and safer then #defining the name of a stdio function name.
    -= Double Post =-
    Zitat Zitat von pspballer07
    Hey Hallo007, my suggestion would be this
    Code:
    //DEFINES
    char fileList[222][200]; //********change from string to char[],  200 is the max filename length
    That would just be plain stupid. STL Strings are much safer then char strings by a mile. ¬¬
    Geändert von yaustar (05-28-2007 um 06:07 AM Uhr) Grund: Automerged Doublepost

  7. #4717
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    I believe the reason people define pspDebugScreenPrintf as printf is to make typing easier, so defining it to a word of about the same length is kinda pointless.
    How about..
    Code:
    #define omgprintf pspDebugScreenPrintf
    There, all better.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  8. #4718
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Spoiler for main.cpp:
    #include <stdlib.h>
    #include <malloc.h>
    #include <pspdisplay.h>
    #include <psputils.h>
    #include <png.h>
    #include <pspgu.h>
    #include <string>
    #include <pspkernel.h>
    #include <pspctrl.h>

    #include "desktop.h"
    #include "graphics/graphics.h"

    #include "io/iO.h"
    #include "variabels.h"

    //DEFINES
    #define blitImage blitAlphaImageToScreen
    #define printg printTextScreen
    #define printf pspDebugScreenPrintf

    //MODULE INFO
    PSP_MODULE_INFO("TEST" , 0x1000, 1, 1);
    PSP_MAIN_THREAD_ATTR(0);
    //100% c++ :P
    using namespace std;

    Image *desktopImages[11];
    Image *desktopBack;




    int LoadStartModule(char *path)
    {
    u32 loadResult;
    u32 startResult;
    int status;

    loadResult = sceKernelLoadModule(path, 0, NULL);
    if (loadResult & 0x80000000) return -1;

    startResult = sceKernelStartModule(load Result, 0, NULL, &status, NULL);

    if (loadResult != startResult) return -2;

    return 0;
    }
    int isFile( string filename)
    {
    SceIoStat stats;
    sceIoGetstat( filename.c_str(), &stats);//get the stats

    if ( stats.st_mode & FIO_S_IFDIR) //directory?
    return 0; //if directory
    else
    return 1; //if file
    }
    int main(SceSize args, void *argp)
    {
    int x = 10; //storage for x coordinate
    int y = 0; //storage for y coordinate
    int mouseX = 10; //storage for mouse coordinates on x-as
    int mouseY = 10; //storage for mouse coordinates on y as
    int imageError = 0; //bool for error on image loading
    string fileBuffer[222]; //for the filelist

    //Pad init
    SceCtrlData pad;
    sceCtrlSetSamplingCycle(0 );
    sceCtrlSetSamplingMode(PS P_CTRL_MODE_ANALOG);

    //init the garphics
    initGraphics();
    pspDebugScreenInit();
    pspDebugScreenClear();

    //Image loading
    Image *iconExample = loadImage("data/desktop/icon.PNG");
    if(iconExample == NULL) imageError = 1;
    Image *iconFolder = loadImage("data/desktop/folder.PNG");
    if(iconFolder == NULL) imageError = 1;
    Image *mouse = loadImage("data/desktop/mouse.PNG");
    if(mouse == NULL) imageError = 1;
    desktopBack = loadImage("data/desktop/wallpaper.PNG");
    if(desktopBack == NULL) imageError = 1;

    if(imageError)//if some images failed to load
    {
    pspDebugScreenClear();
    printf("error : failed to load an image:\n");
    sceKernelSleepThread();
    return 0;
    }

    //Load screenshot module
    LoadStartModule("data/screenshot.prx");

    //get al files stored to a string of a directory
    getFileList("ms0:/");

    while(1)
    {
    blitImage(0 , 0 , desktopBack);//wallpaper
    for(unsigned int loop = 0; loop < sizeof(fileList); loop++ )
    {
    char buffer[10];
    y += 10; //go away from the file name
    if(sizeof(fileList[loop]) > 10)
    {
    strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3);
    strcat(buffer , "..");
    fileBuffer[loop] = buffer;
    }
    else
    {
    fileBuffer[loop] = fileList[loop];
    }
    if(isFile(fileList[loop]))
    {
    blitImage(x , y ,iconExample);
    }
    else
    {
    blitImage(x , y ,iconFolder);
    }
    y += 40;
    printg(x , y , fileBuffer[loop].c_str() , white);

    if(y > 249)
    {
    x += 108;
    y = 10;
    }
    }//end for loop
    printf("STEP 3 DONE , WAIT 5 SECONDS");
    sceKernelDelayThread(5000 000);
    pspDebugScreenClear();
    blitImage(mouseX , mouseY , mouse);
    flipScreen();
    while(1)
    {
    sceCtrlReadBufferPositive (&pad, 1);

    if (pad.Lx < 80) //left
    {
    mouseX -= 10;
    if(mouseX<0) mouseX = 460;
    break;
    }
    if (pad.Lx > 175) //right
    {
    mouseX += 10;
    if(mouseX > 480) mouseX = 0;
    break;
    }
    if (pad.Ly > 175) //down
    {
    mouseY -= 10;
    if(mouseY<0) mouseY = 255;
    break;
    }
    if (pad.Ly < 80) //up
    {
    mouseY += 10;
    if(mouseY > 272) mouseY = 0;
    break;
    }
    if(pad.Buttons & PSP_CTRL_HOME)
    {
    sceKernelExitGame();
    }
    }//end while

    }//end while

    sceKernelSleepThread();
    return 0;
    }


    Spoiler for io.cpp:
    void getFileList(string path)
    {
    SceUID bufferFile;
    int z = 0;

    bufferFile = sceIoDopen(path.c_str());
    if(bufferFile > 0)
    {
    SceIoDirent dir;
    memset(&dir, 0, sizeof(SceIoDirent));
    while(sceIoDread(bufferFi le, &dir) > 0)
    {
    fileList[z] = dir.d_name;
    z++;
    if(z > 222 ) break;
    }
    sceIoDclose(bufferFile);
    }
    }


    a bit rewritten and i still dindt saw a mistakes , there are no warnings either

    aargh dammit , with copy/paste get every space lost:-(

  9. #4719
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    ...I'm missing something.

    Did I say something stupid without realizing it again?
    Forgive me, I'm rather tired right now.
    Anyway, I just meant that stdio defines it, but doesn't use it.
    Stdio declares it as a function prototype, by using the #define printf etc, it is possible that the preprocessor has changed the name of the function prototype depending on the order of files that the preprocessor has gone through.

  10. #4720
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Eek. That is dangerous. I just changed all of my "printf"s to "say". Not because it's short, but because it makes sense.

    However, this is just a temporary solution until my partner creates the bitmap font. SDL_ttf looks a little bit too difficult to work with for what I'm using it for. I'd be doing a lot of metric checking, which could get slow.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  11. #4721
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    anyone saw the error in my code yet?

  12. #4722
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Have you, oh, I don't know, tried running it in PSPLink so you can find out where it crashed? That's generally helpful information.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  13. #4723
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von youresam
    I believe the reason people define pspDebugScreenPrintf as printf is to make typing easier, so defining it to a word of about the same length is kinda pointless.
    How about..
    Code:
    #define omgprintf pspDebugScreenPrintf
    There, all better.
    That is what auto completion is for in text editors and IDEs.

    From: http://www.psp-programming.com/forum...p?topic=2161.0
    Zitat Zitat von Yeldarb
    The thing is, most of the people who are reading these tutorials are extremely beginner (as in first time programming). The point of shortening to printf was to allow them to use other general C tutorials online on the PSP and achieve expected results.

  14. #4724
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Have you, oh, I don't know, tried running it in PSPLink so you can find out where it crashed? That's generally helpful information.
    i dont have a psp

  15. #4725
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Have you, oh, I don't know, tried running it in PSPLink so you can find out where it crashed? That's generally helpful information.
    Or just set up an exception handler and use psp-addr2line? Would be much more helpful
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  16. #4726
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    That's also helpful if you're writing a kernel mode application, I guess. Although--
    Zitat Zitat von hallo007
    i dont have a psp
    Um...then how are you testing this?
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  17. #4727
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    friends / beta testers

    i found out it crashes here:
    Code:
        while(1)
        {            
                blitImage(0 , 0 , desktopBack);//wallpaper
                for(unsigned int loop = 0; loop < sizeof(fileList); loop++ )
                {
                      char buffer[10];
                      y += 10; //go away from the file name
                      if(sizeof(fileList[loop]) > 10)
                      {
                                         strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3);
                                         strcat(buffer , "..");
                                         fileBuffer[loop] = buffer;
                                         }
                      else
                      {
                           fileBuffer[loop] = fileList[loop];
                           }
                     if(isFile(fileList[loop]))
                     {
                           blitImage(x , y ,iconExample);
                           }
                     else
                     {
                           blitImage(x , y ,iconFolder);
                           }    
                      y += 40;    
                      printg(x , y , fileBuffer[loop].c_str() , white);
                
                      if(y > 249)
                      {
                          x += 108;
                          y = 10;
                          } 
                          }
    anyone see something?

  18. #4728
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Did you try any debugging methods?

  19. #4729
    QJ Gamer Green
    Points: 4.824, Level: 44
    Level completed: 37%, Points required for next Level: 126
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    317
    Points
    4.824
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    friends / beta testers

    i found out it crashes here:
    Code:
        while(1)
        {            
                blitImage(0 , 0 , desktopBack);//wallpaper
                for(unsigned int loop = 0; loop < sizeof(fileList); loop++ )
                {
                      char buffer[10];
                      y += 10; //go away from the file name
                      if(sizeof(fileList[loop]) > 10)
                      {
                                         strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3);
                                         strcat(buffer , "..");
                                         fileBuffer[loop] = buffer;
                                         }
                      else
                      {
                           fileBuffer[loop] = fileList[loop];
                           }
                     if(isFile(fileList[loop]))
                     {
                           blitImage(x , y ,iconExample);
                           }
                     else
                     {
                           blitImage(x , y ,iconFolder);
                           }    
                      y += 40;    
                      printg(x , y , fileBuffer[loop].c_str() , white);
                
                      if(y > 249)
                      {
                          x += 108;
                          y = 10;
                          } 
                          }
    anyone see something?
    If it doesn't compile right it's because you are declaring the unsigned int loop in the for statement. In C, you have to declare it out of or right before the for statement like this:
    Code:
    unsigned int loop;
    for(loop = 0; loop<whatever;loop++)
    {
    }
    Current releases:
    Icon Action Replacer v1.5- latest release
    Current projects:
    PSP C++ IDE - Currently v1.6
    RPG Paradise - Latest version at my website

  20. #4730
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Take a look at the code for a moment and you'll see this: "fileBuffer[loop].c_str()". He's using STL strings, which means that this is C++, therefore it's valid. Also, he said it was crashing, which means it must be compiling.

    E] Wait, where's buffer defined?
    E2] Nevermind, I see it now.
    Geändert von Archaemic (05-28-2007 um 09:09 AM Uhr)
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  21. #4731
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    string fileBuffer[222]; ?

    no i dindt tried the debugging methods because i havent got a psp and my friends havent got cygwin or the knowledge to use it

  22. #4732
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    ...

    Member that little lesson we gave you on using #define, #ifdef, and #ifndef to debug?

  23. #4733
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    o yeah , wait it is a few pages back

    i thought you mean psplink;-)
    -= Double Post =-
    #define DEBUG

    #ifdef DEBUG
    ...
    #endif


    but what is this gong to help?
    Geändert von hallo007 (05-28-2007 um 09:09 AM Uhr) Grund: Automerged Doublepost

  24. #4734
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Code:
                      char buffer[10];
                      y += 10; //go away from the file name
                      if(sizeof(fileList[loop]) > 10)
                      {
                                         strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3);
                                         strcat(buffer , "..");
                                         fileBuffer[loop] = buffer;
                                         }
    This is terribly unsafe. If you're going to strcat it, at least make sure to memset buffer to 0 first, otherwise you'll have an instant buffer overflow right there.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  25. #4735
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    sizeof(buffer) - 3

    i reserved two bytes for the ".."

  26. #4736
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You are using C++ strings dammit. Use C++ string operations !!
    http://www.cppreference.com/cppstring/append.html
    -= Double Post =-
    Code:
    if(sizeof(fileList[loop]) > 10)
    This does not work C++ strings are objects and hold extra data besides the actual char string.
    http://www.cppreference.com/cppstring/length.html
    Geändert von yaustar (05-28-2007 um 09:27 AM Uhr) Grund: Automerged Doublepost

  27. #4737
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    sizeof(buffer) - 3

    i reserved two bytes for the ".."
    That's not where the overflow is coming from. The overflow is coming from the fact that the memory allocated is not necessarily all 0. It could be a (seemingly) random string of characters.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  28. #4738
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    o yeah , wait it is a few pages back

    i thought you mean psplink;-)
    -= Double Post =-
    #define DEBUG

    #ifdef DEBUG
    ...
    #endif


    but what is this gong to help?
    Are you serious?

  29. #4739
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    yes I am

    thnx yauster , i take a look

  30. #4740
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Why can no one spell yaustar? Honestly, it's not that hard to remember.

    Anyway, you'd use the conditionals to print stuff out in debug mode so you can isolate the crash. No PSPLink necessary. It's tedious, but it works.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:15 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .