Idk what happened

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
ansem227
Posts: 1
Joined: Mon Mar 13, 2006 7:21 am

Idk what happened

Post by ansem227 »

ok im a new at programming
but im only 14 years old
and ive been looking at this forum for a bit now and
i final have a problem and i hope someone can help me
but i tried to make my program with cygwin and it worked b4 and then i tryed to make it agian and this happened

Code: Select all

Mine@mine /projects/helloworld2
$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall   -c -o main.o mai
n.c
main.c: In function 'main':
main.c:63: warning: unused variable 't'
main.c:62: warning: unused variable 'g'
main.c:61: warning: unused variable 'i'
main.c:58: warning: unused variable 'pad'
main.c: At top level:
main.c:67: error: syntax error before string constant
main.c:67: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:67: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:67: warning: data definition has no type or storage class
main.c:68: error: syntax error before string constant
main.c:68: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:68: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:68: warning: data definition has no type or storage class
main.c:69: error: syntax error before string constant
main.c:69: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:69: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:69: warning: data definition has no type or storage class
main.c:70: error: syntax error before string constant
main.c:70: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:70: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:70: warning: data definition has no type or storage class
main.c:71: error: syntax error before string constant
main.c:71: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:71: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:71: warning: data definition has no type or storage class
main.c:79: error: syntax error before string constant
main.c:79: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:79: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:79: warning: data definition has no type or storage class
main.c:85: warning: type defaults to 'int' in declaration of 'pspDebugScreenClea
r'
main.c:85: error: conflicting types for 'pspDebugScreenClear'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:96: error: previous declaration of
'pspDebugScreenClear' was here
main.c:85: warning: data definition has no type or storage class
main.c:86: error: syntax error before '+=' token
main.c:93: error: syntax error before string constant
main.c:93: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:93: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:93: warning: data definition has no type or storage class
main.c:94: error: syntax error before string constant
main.c:94: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:94: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:94: warning: data definition has no type or storage class
main.c:101: warning: type defaults to 'int' in declaration of 'pspDebugScreenCle
ar'
main.c:101: error: conflicting types for 'pspDebugScreenClear'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:96: error: previous declaration of
'pspDebugScreenClear' was here
main.c:101: warning: data definition has no type or storage class
main.c:102: error: syntax error before string constant
main.c:102: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:102: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:102: warning: data definition has no type or storage class
main.c:103: error: syntax error before string constant
main.c:103: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:103: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:103: warning: data definition has no type or storage class
main.c:104: error: syntax error before string constant
main.c:104: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:104: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:104: warning: data definition has no type or storage class
main.c:113: warning: type defaults to 'int' in declaration of 'pspDebugScreenCle
ar'
main.c:113: error: conflicting types for 'pspDebugScreenClear'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:96: error: previous declaration of
'pspDebugScreenClear' was here
main.c:113: warning: data definition has no type or storage class
main.c:114: error: syntax error before string constant
main.c:114: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:114: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:114: warning: data definition has no type or storage class
main.c:115: error: syntax error before string constant
main.c:115: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:115: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:115: warning: data definition has no type or storage class
main.c:116: error: syntax error before string constant
main.c:116: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:116: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:116: warning: data definition has no type or storage class
main.c:138: error: syntax error before string constant
main.c:138: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:138: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:138: warning: data definition has no type or storage class
main.c:139: error: syntax error before '+=' token
main.c:145: error: syntax error before string constant
main.c:145: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:145: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:145: warning: data definition has no type or storage class
main.c:146: error: syntax error before '+=' token
main.c:154: error: syntax error before string constant
main.c:154: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:154: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:154: warning: data definition has no type or storage class
main.c:155: error: syntax error before string constant
main.c:155: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:155: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:155: warning: data definition has no type or storage class
main.c:156: error: syntax error before string constant
main.c:156: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:156: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:156: warning: data definition has no type or storage class
main.c:157: error: syntax error before string constant
main.c:157: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:157: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:157: warning: data definition has no type or storage class
main.c:158: error: syntax error before string constant
main.c:158: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:158: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:158: warning: data definition has no type or storage class
main.c:159: error: syntax error before string constant
main.c:159: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:159: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:159: warning: data definition has no type or storage class
main.c:160: error: syntax error before string constant
main.c:160: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:160: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:160: warning: data definition has no type or storage class
main.c:161: error: syntax error before string constant
main.c:161: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:161: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:161: warning: data definition has no type or storage class
main.c:162: error: syntax error before string constant
main.c:162: warning: type defaults to 'int' in declaration of 'pspDebugScreenPri
ntf'
main.c:162: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:40: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:162: warning: data definition has no type or storage class
make: *** [main.o] Error 1
and my code is

Code: Select all


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>

#define printf pspDebugScreenPrintf
#define N 100




PSP_MODULE_INFO&#40;"The Guessing Game", 0, 1, 1&#41;;


/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;

          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;

          sceKernelSleepThreadCB&#40;&#41;;

          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;

          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;

          return thid;
&#125;


int main&#40;&#41; &#123;
    

    SceCtrlData pad;
    pspDebugScreenInit&#40;&#41;;
    SetupCallbacks&#40;&#41;;
    int i = 1;
    int g = 1;
    int t = 1;


&#125;
        printf&#40;"     ___     _  _    ___    ___   ___ ___    ___    ___    ____  \n"&#41;;
        printf&#40;"    / _ \\   | \\| |  | __|  | __| |   V   |  |_  |  |_  |  |__  | \n"&#41;;
        printf&#40;"   / /_\\ \\  |    |  |__ |  | __| | |\\_/| |   / /_   / /_    / / \n"&#41;;
        printf&#40;"  /_/   \\_\\ |_|\\_|  |___|  |___| |_|   |_|  |____| |____|  /_/ \n"&#41;;
    printf&#40;"Press &#91;X&#93; To Make a Random Number\n"&#41;;
while&#40;1&#41;
    &#123;
         sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
  if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
                    break;
          &#125;
&#125;
    printf&#40;"Press &#91;O&#93; To Make a Random Number\n"&#41;;
while&#40;1&#41; &#123;
          sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
          if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; &#123;
                    break;
          &#125;
          pspDebugScreenClear&#40;&#41;;
          i += 1;
          if &#40;i > 500&#41;
            &#123;
                 i = 1;
                 &#125;
    &#125;

    printf&#40;"Ok now for the game\n"&#41;;
    printf&#40;"guess a number &#40;1-500&#41;\n"&#41;;
while&#40;1&#41; &#123;

         sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
    if &#40;pad.Buttons & PSP_CTRL_UP&#41;
    &#123;
                    g += 1;
                    pspDebugScreenClear&#40;&#41;;
                    printf&#40;"Ok now for the game\n"&#41;;
                    printf&#40;"guess a number &#40;1-500&#41;\n"&#41;;
                    printf&#40;"%d\n",g&#41;;
                        if &#40;g > 500&#41;
                    &#123;
                    g = 1;                    
                      &#125;
                    &#125;
    if &#40;pad.Buttons & PSP_CTRL_DOWN&#41;
    &#123;
                    g -= 1;
                    pspDebugScreenClear&#40;&#41;;
                    printf&#40;"Ok now for the game\n"&#41;;
                    printf&#40;"guess a number &#40;1-500&#41;\n"&#41;;
                    printf&#40;"%d\n",g&#41;;
                        if &#40;g < 1&#41;
                    &#123;
                    g = 500;                    
                          &#125;
                    &#125;


    if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;
    &#123;
                    if &#40;g == i&#41;
                    &#123;
                          pspDebugScreenClear&#40;&#41;;
                    &#123;
                    break;
          &#125;
                          
                          &#125;
                    
                    if &#40;g > i&#41;
                    &#123;
                          pspDebugScreenClear&#40;&#41;;
                          printf&#40;"Two High try agian"&#41;;
                          t += 1;
                          &#125;
                    
                    if &#40;g < i&#41;
                    &#123;
                          pspDebugScreenClear&#40;&#41;;
                          printf&#40;"Two Low try agian"&#41;;
                          t += 1;
                          &#125;
                    
                    &#125;
    
&#125;
while &#40;1&#41; &#123;
      printf&#40;"W     \n"&#41;;
      printf&#40;" I    \n"&#41;;
      printf&#40;"  N   \n"&#41;;
      printf&#40;"   N  \n"&#41;;
      printf&#40;"    E \n"&#41;;
      printf&#40;"     R\n"&#41;;
      printf&#40;"      \n"&#41;;
      printf&#40;"      \n"&#41;;
      printf&#40;"WINNER\n"&#41;;
      printf&#40;"In %d Tries\n",t&#41;;

      &#125;



&#125;
and i no the code my be sloppy
and im sorry
urchin
Posts: 121
Joined: Thu Jun 02, 2005 5:41 pm

Post by urchin »

Look through the compiler messages for the first error (not warning). In this case:

Code: Select all

main.c&#58;67&#58; error&#58; syntax error before string constant 
This gives you a clue that the first problem is in your main function. You have an extra "}" above the first printf which ends the function too early.
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

You have quite alot of erros in there, almost all syntax when looking at it

Get Ultra Edit or Dev-C++ and click -> on the keyboard alot until you reacha '{' or '[' or '(' then scroll thro your code with your mouse and make sure the 2 'brackets' 'prenethesis' or '[ ]' match up with what thye bare supposed to, and if you see when on 'int main() {' the { highlight, then scroll down and see a nother one highlioghted half way through, thats saying you have an extra or added code after the 'main' rpgoram resulting in a complie error.

Look over your code right now, right after you declare your variables and 'initializex them' you closed your main program meaning your done, thats why your getting soooo many errors

And your 'int main() {' is has to return something, add a return 0; right before closing the main program.

OFF TOPIC: I too am 14 years old
HaQue
Posts: 91
Joined: Fri Nov 25, 2005 8:52 am
Location: Adelaide, Australia
Contact:

Post by HaQue »

If it helps, try some comments to help you.

comments:

Code: Select all


int main&#40;&#41; &#123;
    while&#40;true&#41; &#123;
        if &#40;a < b&#41; &#123;
            if &#40;c == b&#41; &#123;
                doAnotherThing&#40;&#41;;
            &#125; // ends if
            doSomething&#40;&#41;;
        &#125; // ends if
    &#125; // ends while
&#125; // ends main function
no comments

Code: Select all


int main&#40;&#41; &#123;
    while&#40;true&#41; &#123;
        if &#40;a < b&#41; &#123;
            if &#40;c == b&#41; &#123;
                doAnotherThing&#40;&#41;;
            &#125;
            doSomething&#40;&#41;;
        &#125;
    &#125;
&#125;
see the difference? It is SO easy to add too many barckets, especially in game programming where there are alot of conditional statements
Post Reply