#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    22
    Rep Power
    0

    Need help debug Problem


    hello to all

    I wrote a program in c a Assembler code and I get this compiler Message.

    I worte the line that I have error:
    PHP Code:

    l
    [12]={"stop",0,1,"add",1,1,"sub",2,1,"mult",3,1,"mover",4,1,"movm",5,1
            
    "comp",6,1,"bc",7,1,"div",8,1,"read",9,1,"print",10,1};

    [
    Errorexpected '}' before string constant 
    PHP Code:
    fprintf(fe," Error at line %d :: Illegal register %s",lnctr 1,buf.op1);

    [
    Errorexpected ')' before numeric constant 
    PHP Code:
    fprintf(fo,"%d)00 0 001  \n,lc);

    [Warning] missing terminating " 
    character [enabled by default] 
    PHP Code:
    fprintf(fo,"%d)00 0 001  \n,lc);

    [Error] missing terminating " 
    character 
    PHP Code:
    update_symtab(fe));

    [
    Errorinvalid use of void expression 
    PHP Code:
    #include <stdio.h>
    In function 'pass1':

    this is the function pass1 Signature

    void pass1
    (FILE *fe,FILE *fo
    I cant find what is Wrong
    I would appreciate any help on the subject

    best regards
    tamir
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,175
    Rep Power
    2222
    Originally Posted by tamir yosef
    Code:
    l[12]={"stop",0,1,"add",1,1,"sub",2,1,"mult",3,1,"mover",4,1,"movm",5,1
            "comp",6,1,"bc",7,1,"div",8,1,"read",9,1,"print",10,1};
    
    [Error] expected '}' before string constant
    What data type is l? I assume that it's a struct. So each element's fields need to be grouped together. The way you've written it, the compiler thinks that l[0] is "stop", l[1] is 0, etc.

    That would start:
    Code:
    l[12]={ {"stop",0,1}, {"add",1,1} ,
    I'll let you do the rest.

    And BTW, l is not a good name for a variable. Not only does the name not tell you anything about what it represents, but in many fonts it would be indistinguishable from a 1 (one).

    Originally Posted by tamir yosef
    Code:
    fprintf(fe," Error at line %d :: Illegal register %s",lnctr 1,buf.op1);
    
    [Error] expected ')' before numeric constant
    What is lnctr 1? C syntax does not support anything like that.

    Originally Posted by tamir yosef
    Code:
    fprintf(fo,"%d)00 0 001  \n,lc);
    
    [Warning] missing terminating " character [enabled by default]
    Never use a word processor to write code! Compilers expect normal double quotes. Word processors do not write normal double quotes! Instead they throw in those fancy slanty things which are not the double quotes that compilers expect!

    And never use a word processor to write code!

    Originally Posted by tamir yosef
    Code:
    fprintf(fo,"%d)00 0 001  \n,lc);
    
    [Error] missing terminating " character
    Same thing. It's that stupid word processor.

    Never use a word processor to write code!

    Originally Posted by tamir yosef
    Code:
    update_symtab(fe));
    
    [Error] invalid use of void expression
    No idea. You lifted that completely out of any context that could give it any meaning. I can tell because there's an extra close parenthesis. Is this function's return value being passed to another function? Does this function even have a return value? Or is it a void function? The error message seems to indicate that it's a void function. How could a void function possibly supply any value to serve as an argument for another function? Assuming that that is what's happening here.

    Originally Posted by tamir yosef
    Code:
    #include <stdio.h>
    In function 'pass1':
    
    this is the function pass1 Signature
    
    void pass1(FILE *fe,FILE *fo)
    No idea. We don't have the context. We don't even have what the error/warning message was.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    22
    Rep Power
    0
    thanks I fix most of the error

    I still cant fix that

    PHP Code:
    struct mnemtab{
         
    char mnem[20];
         
    int opcode;
         
    int len;
    }
    l[12]={{"stop",0,1},{"add",1,1},{"sub",2,1},{"mult",3,1},{"mover",4,1},{"movm",5,1}
          {
    "comp",6,1},{"bc",7,1},{"div",8,1},{"read",9,1},{"print",10,1}}; 
    I still get this massage
    [Error] expected '}' before '{' token
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    22
    Rep Power
    0
    ohhh I miss this , :eek:

    now I get only this

    clrscr();

    undefined reference to `clrscr'
    [Error] ld returned 1 exit status

    on the start of the program I defined so why I get not defined??

    I defined #include <conio.h>
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,175
    Rep Power
    2222
    #include only inserts the file into the source. You use it to insert header files which contain information about other source files and libraries that you are linking in to your project. Header files such as stdio.h are for the Standard C Library, which it automatically linking in.

    conio is not part of the Standard C Library, but rather is a third party library. #include'ing the conio.h header file only tells the compiler about what's in that library, but it does not link in the library itself. You need to tell the project to link in the conio library.

    BTW, ld is the linker, so that is indeed a linker error. What are you using? An IDE that uses MinGW gcc? If you look in the INCLUDE directory, you may find a source file, conio.c. Use it.
  10. #6
  11. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,175
    Rep Power
    2222
    Originally Posted by tamir yosef
    thanks I fix most of the error

    I still cant fix that

    PHP Code:
    struct mnemtab{
         
    char mnem[20];
         
    int opcode;
         
    int len;
    }
    l[12]={{"stop",0,1},{"add",1,1},{"sub",2,1},{"mult",3,1},{"mover",4,1},{"movm",5,1}
          {
    "comp",6,1},{"bc",7,1},{"div",8,1},{"read",9,1},{"print",10,1}}; 
    I still get this massage
    [Error] expected '}' before '{' token
    You need a comma between each element of the array. Remember, one of the first things the compilers does is strip out all extra whitespace, including newlines. If you have difficulty with those concepts, think of how you write the arguments in a function call that wraps around to the next line; you don't leave out any of the commas there, do you?

    Where's the comma between the "movm" and the "comp" fields?

    If you
    Last edited by dwise1_aol; October 6th, 2013 at 02:57 PM.

IMN logo majestic logo threadwatch logo seochat tools logo