Compiling error: expected identifier or ‘(’ before ‘{’ token

Discussion in 'C Programming' started by aydinh, Mar 10, 2010.

  1. aydinh

    aydinh Guest

    Hi I've been writing a piece of code as part of university course and
    I am getting an error and I can't figure out how to fix it.

    The code is meant to be a reverse polish notation calculator, the user
    inputs digits and operators one at a time and the program either
    pushes the numbers on to a stack or pops them off when it receives an
    operator, performs the calculation, then pushes the result back on to
    the stack.

    Finally when the user inputs a equals sign the program displays the
    results, this is how it's meant to work anyway.

    When I try to compile i get this error:
    prog5.c:10: error: expected identifier or ‘(’ before ‘{’ token

    BTW the simpleio.h is a library of input mechanisms given to us by our
    university, they include the getInt() & getChar functions, supposedly
    there to make our lives easier, anyway, the code:

    #include <stdio.h>
    #include <stdlib.h>
    #include "../simpleio.h"

    typedef struct CalcParam { int item;
    struct calcParam * next;
    } calcParam;

    int main();
    {
    char item;
    int temp1, temp2, temp3, answer;
    calcParam * top;
    calcParam * cpp;

    printf("Enter a reverse polish notation string, character by
    character: \n");
    printf("Finish with '='\n");
    printf("Next: "); item=getChar();

    while(item!='=')
    {
    if (!(item>='0' && item<='9' || item=='+' || item=='-' || item=='*'
    || item=='/' ) //ccheck if input is valid
    {
    printf("Not a valid input, valid input: digits 0-9, +, -, *, /");
    exit(1)
    }

    if (item>='0' && item<='9') //check if user input is a
    number
    {
    if(!(cpp = (calcParam *) malloc(sizeof(calcParam)); //check if
    memory can be allocated
    {
    printf("Cannot allocate memory\n");
    exit(1);
    }
    atoi(&item); //convert input char to int ready to push on
    to stack
    cpp->item=item; //push number on to stack
    cpp->next = top;
    top = cpp;
    printf("Next: "); item=getChar();
    }
    if (item=='+' || item=='-' || item=='*' || item=='/') //
    check if user input is an operator
    {
    temp1=top->item; //pop first item and put it in
    temp1
    cpp = top;
    top = top->next;
    free(ccp);
    temp2=top->item; //pop second item and put it in
    temp2
    cpp = top;
    top = top->next;
    free(ccp);
    temp3 = temp2 item temp1; //perform arithmetic and
    store answer in temp3

    if(!(cpp = (calcParam *) malloc(sizeof(calcParam)); //
    check if memory can be allocated
    {
    printf("Cannot allocate memory\n");
    exit(1);
    }
    cpp->item=temp3; //push temp3 on to stack
    cpp->next = top;
    top = cpp;
    printf("Next: "); item=getChar();
    }
    }
    answer=top->item; //pop answer
    cpp = top;
    top = top->next;
    free(ccp);
    printf("Answer: ", answer);
    return 0;
    }
    aydinh, Mar 10, 2010
    #1
    1. Advertising

  2. aydinh

    Tom St Denis Guest

    On Mar 10, 7:51 am, aydinh <> wrote:
    > int main();
    > {


    Here's your problem.

    Tom
    Tom St Denis, Mar 10, 2010
    #2
    1. Advertising

  3. On 10 Mar, 12:51, aydinh <> wrote:

    > Hi I've been writing a piece of code as part of university course and
    > I am getting an error and I can't figure out how to fix it.


    <snip>

    > When I try to compile i get this error:
    > prog5.c:10: error: expected identifier or ‘(’ before ‘{’ token


    it would be nice if you indicated which was line 10. I know we can
    count but the posting process can mess things up. And suppose it was
    big number line 199, do I have to count that many lines to help you?

    > BTW the simpleio.h is a library of input mechanisms given to us by our
    > university, they include the getInt() & getChar functions, supposedly
    > there to make our lives easier, anyway, the code:
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include "../simpleio.h"
    >
    > typedef struct CalcParam {  int item;
    >                             struct calcParam * next;


    I think you meant "struct CalcParam". Is this your actual code?

    >                             } calcParam;
    >
    > int main();
    > {
    >         char item;


    I can find your error by inspection but you should learn to do this
    yourself. Which line was the error reported on? What came just before
    the { ? Ignore spaces, tabs and newlines. Now go and look in your
    textbook or course notes. How is a function defined?


    <snip>
    Nick Keighley, Mar 10, 2010
    #3
  4. On 10 Mar, 12:51, aydinh <> wrote:

    <snip>

    > The code is meant to be a reverse polish notation calculator, the user
    > inputs digits and operators one at a time and the program either
    > pushes the numbers on to a stack or pops them off when it receives an
    > operator, performs the calculation, then pushes the result back on to
    > the stack.
    >
    > Finally when the user inputs a equals sign the program displays the
    > results, this is how it's meant to work anyway.
    >
    > When I try to compile i get this error:
    > prog5.c:10: error: expected identifier or ‘(’ before ‘{’ token


    I dealt witht he error in another post


    > BTW the simpleio.h is a library of input mechanisms given to us by our
    > university, they include the getInt() & getChar functions, supposedly
    > there to make our lives easier, anyway, the code:
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include "../simpleio.h"
    >
    > typedef struct CalcParam {  int item;
    >                             struct calcParam * next;
    >                             } calcParam;
    >
    > int main();
    > {
    >         char item;
    >         int temp1, temp2, temp3, answer;


    variables called temp1, temp2 and temp3 are usually a bad sign. Have
    you done arrays yet?

    >         calcParam * top;
    >         calcParam * cpp;
    >
    >         printf("Enter a reverse polish notation string, character by
    > character: \n");
    >         printf("Finish with '='\n");
    >         printf("Next: "); item=getChar();
    >
    >         while(item!='=')


    did you use up your allocation of spaces? I'd code this as

    while (item != '=')

    >         {
    >                 if (!(item>='0' && item<='9' || item=='+' || item=='-' || item=='*'
    > || item=='/' )  //ccheck if input is valid


    have you be told about isdigit()? I'd worry about the precedence of &&
    and ||. I * think* the above is correct but I'd check.


    >                 {
    >                         printf("Not a valid input, valid input: digits 0-9, +, -, *, /");
    >                         exit(1)


    technically 1 (one) is a not a portable value to pass to exit().
    Though it's going to work most places.

    >                 }
    >
    >                 if (item>='0' && item<='9')                                                               //check if user input is a
    > number


    // comments don't work on older compilers and get messed up by posting
    s/w (as here).


    >                 {
    >                         if(!(cpp = (calcParam *) malloc(sizeof(calcParam));                             //check if
    > memory can be allocated


    is malloc() really necessary? Your stack is a list of calcParams? You
    chekced the return value of malloc()- good! The cast is unnecessary in
    C.

    >                         {
    >                                 printf("Cannot allocate memory\n");
    >                                 exit(1);
    >                         }


    >                         atoi(&item);    


    you ignore the return value of atoi(). atoi() expects a string you
    can't give it the address of a char. Review your pointer stuff. atoi()
    has no error checking but I suppose that's ok for a learner.
     
    >                         cpp->item=item;


    I've removed some of your comments as the layout had gone *really*
    strange

    >                         cpp->next = top;
    >                         top = cpp;
    >                         printf("Next: "); item=getChar();
    >                 }
    >                 if (item=='+' || item=='-' || item=='*' || item=='/')    
    >             {
    >                         temp1=top->item;  


    where was top initialised (I may have missed it). Have you done
    functions yet? push and pop probably should be functions.
         
    > >                         cpp = top;

    >                         top = top->next;
    >                         free(ccp);
    >                         temp2=top->item;                                                             //pop second item and put it in
    > temp2


    I hate comments like this! We *know* you are storing it in temp2.

    >                         cpp = top;
    >                         top = top->next;
    >                         free(ccp);
    >                         temp3 = temp2 item temp1;                                                       //perform arithmetic and
    > store answer in temp3
    >
    >                         if(!(cpp = (calcParam *) malloc(sizeof(calcParam));                             //
    > check if memory can be allocated
    >                         {
    >                                 printf("Cannot allocate memory\n");
    >                                 exit(1);
    >                         }
    >                         cpp->item=temp3;                                                             //push temp3 on to stack
    >                         cpp->next = top;
    >                         top = cpp;
    >                         printf("Next: "); item=getChar();
    >                 }
    >         }
    >         answer=top->item;                                                                            //pop answer
    >         cpp = top;
    >         top = top->next;
    >         free(ccp);
    >         printf("Answer: ", answer);
    >         return 0;
    >
    >
    >
    > }
    Nick Keighley, Mar 10, 2010
    #4
  5. aydinh

    aydinh Guest

    On Mar 10, 1:04 pm, Nick Keighley <>
    wrote:
    > On 10 Mar, 12:51, aydinh <> wrote:
    >
    > > Hi I've been writing a piece of code as part of university course and
    > > I am getting an error and I can't figure out how to fix it.

    >
    > <snip>
    >
    > > When I try to compile i get this error:
    > > prog5.c:10: error: expected identifier or ‘(’ before ‘{’ token

    >
    > it would be nice if you indicated which was line 10. I know we can
    > count but the posting process can mess things up. And suppose it was
    > big number line 199, do I have to count that many lines to help you?
    >
    > > BTW the simpleio.h is a library of input mechanisms given to us by our
    > > university, they include the getInt() & getChar functions, supposedly
    > > there to make our lives easier, anyway, the code:

    >
    > > #include <stdio.h>
    > > #include <stdlib.h>
    > > #include "../simpleio.h"

    >
    > > typedef struct CalcParam {  int item;
    > >                             struct calcParam * next;

    >
    > I think you meant "struct CalcParam". Is this your actual code?
    >
    > >                             } calcParam;

    >
    > > int main();
    > > {
    > >         char item;

    >
    > I can find your error by inspection but you should learn to do this
    > yourself. Which line was the error reported on? What came just before
    > the { ? Ignore spaces, tabs and newlines. Now go and look in your
    > textbook or course notes. How is a function defined?
    >
    > <snip>


    line 10 is the line after int main, which as pointed out above I
    ridiculously left in a semi-colon without noticing :(, the definition
    of struct calcParam is right, and yes it is my own code.
    aydinh, Mar 10, 2010
    #5
  6. aydinh

    aydinh Guest

    Thanks for all the comments, the code works now and I am going to read
    through all your suggestions, I have learnt functions and arrays, but
    this exercise is under the lab worksheet for malloc, so I guess it's
    best I use malloc.

    I do understand the precedence of || and &&, but haven't come across
    isdigit, will look in to it.

    exit(1) is just what I have been shown by my lecturer, I know no other
    way :(

    I did forget to initialise top, I have amended it and it now looks
    like this: calcParam * top = NULL;

    Sorry about the annoying comments :(
    aydinh, Mar 10, 2010
    #6
  7. On 10 Mar, 13:21, aydinh <> wrote:
    > On Mar 10, 1:04 pm, Nick Keighley <>
    > > On 10 Mar, 12:51, aydinh <> wrote:


    <snip>

    > > > typedef struct CalcParam {  int item;
    > > >                             struct calcParam * next;

    >
    > > I think you meant "struct CalcParam". Is this your actual code?

    >
    > > >                             } calcParam;


    <snip>

    > line 10 is the line after int main, which as pointed out above I
    > ridiculously left in a semi-colon without noticing :(,


    it happens! But the compiler tries its best to help!

    > the definition
    > of struct calcParam is right, and yes it is my own code.


    must be me. I'd expect

    typedef struct CalcParam { int item;
    struct CalcParam * next;
    } calcParam;

    I'm surprised it can "see" calcParam when next is defined.
    Nick Keighley, Mar 10, 2010
    #7
  8. aydinh

    aydinh Guest

    > I'm surprised it can "see" calcParam when next is defined.

    I know what you mean, but this is how I've been shown to do it, and
    both my reference books say to do it this way.
    aydinh, Mar 10, 2010
    #8
  9. On 2010-03-10, aydinh <> wrote:
    > Hi I've been writing a piece of code as part of university course and
    > I am getting an error and I can't figure out how to fix it.
    >
    > The code is meant to be a reverse polish notation calculator, the user
    > inputs digits and operators one at a time and the program either
    > pushes the numbers on to a stack or pops them off when it receives an
    > operator, performs the calculation, then pushes the result back on to
    > the stack.
    >
    > Finally when the user inputs a equals sign the program displays the
    > results, this is how it's meant to work anyway.
    >
    > When I try to compile i get this error:
    > prog5.c:10: error: expected identifier or ?(? before ?{? token
    >
    > BTW the simpleio.h is a library of input mechanisms given to us by our
    > university, they include the getInt() & getChar functions, supposedly
    > there to make our lives easier, anyway, the code:
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include "../simpleio.h"
    >
    > typedef struct CalcParam { int item;
    > struct calcParam * next;
    > } calcParam;
    >
    > int main();


    Compilation fails here, as your compiler as told you.

    > {
    > char item;


    Don't use tabs. Your lines are too long even without them. My newsreader
    will complain when I try to post this because I've quoted /your/ lines.
    Ergo, you need a smarter newsreader. Try slrn.

    > int temp1, temp2, temp3, answer;
    > calcParam * top;
    > calcParam * cpp;
    >
    > printf("Enter a reverse polish notation string, character by
    > character: \n");


    Character by character? Surely you can do better than that.

    > printf("Finish with '='\n");
    > printf("Next: "); item=getChar();
    >
    > while(item!='=')


    What if item is EOF?

    > {
    > if (!(item>='0' && item<='9' || item=='+' || item=='-' || item=='*'
    >|| item=='/' ) //ccheck if input is valid


    Please stop using // comments. I can't even count all the syntax
    errors you've caused by them wrapping around all over the place.

    > {
    > printf("Not a valid input, valid input: digits 0-9, +, -, *, /");
    > exit(1)


    Compilation will fail here. Plus 1 is not a valid return value on
    all systems. stdlib.h has a constant EXIT_FAILURE you can use for
    that purpose.

    > }
    >
    > if (item>='0' && item<='9') //check if user input is a
    > number


    See ctype.h and isdigit().

    > {
    > if(!(cpp = (calcParam *) malloc(sizeof(calcParam)); //check if
    > memory can be allocated


    This is a terrible use of malloc(). Try:

    cpp = malloc(sizeof *cpp)

    > {
    > printf("Cannot allocate memory\n");
    > exit(1);
    > }
    > atoi(&item); //convert input char to int ready to push on
    > to stack


    What do you expect the to do? And how?

    > cpp->item=item; //push number on to stack
    > cpp->next = top;
    > top = cpp;
    > printf("Next: "); item=getChar();
    > }
    > if (item=='+' || item=='-' || item=='*' || item=='/') //
    > check if user input is an operator
    > {
    > temp1=top->item; //pop first item and put it in
    > temp1
    > cpp = top;
    > top = top->next;
    > free(ccp);
    > temp2=top->item; //pop second item and put it in
    > temp2
    > cpp = top;
    > top = top->next;
    > free(ccp);
    > temp3 = temp2 item temp1; //perform arithmetic and
    > store answer in temp3


    What do you expect this to do? And how?

    >
    > if(!(cpp = (calcParam *) malloc(sizeof(calcParam)); //
    > check if memory can be allocated
    > {
    > printf("Cannot allocate memory\n");
    > exit(1);
    > }
    > cpp->item=temp3; //push temp3 on to stack
    > cpp->next = top;
    > top = cpp;
    > printf("Next: "); item=getChar();


    Why did you duplicate this line?

    > }
    > }
    > answer=top->item; //pop answer
    > cpp = top;
    > top = top->next;
    > free(ccp);


    This is pointless. If you're going to free anything why don't
    you free the entire list?

    > printf("Answer: ", answer);
    > return 0;
    > }



    --
    Andrew Poelstra
    http://www.wpsoftware.net/andrew
    Andrew Poelstra, Mar 10, 2010
    #9
  10. Re:Re: Compiling error: expected identifier or ‘(’ before ‘{’ token

    On 2010-03-10, aydinh <> wrote:
    >> I'm surprised it can "see" calcParam when next is defined.

    >
    > I know what you mean, but this is how I've been shown to do it, and
    > both my reference books say to do it this way.


    Throw them both out. They're garbage.

    --
    Andrew Poelstra
    http://www.wpsoftware.net/andrew
    Andrew Poelstra, Mar 10, 2010
    #10
  11. On 2010-03-10, Andrew Poelstra <> wrote:
    > On 2010-03-10, aydinh <> wrote:
    >
    >> char item;

    >
    > Don't use tabs. Your lines are too long even without them. My newsreader
    > will complain when I try to post this because I've quoted /your/ lines.
    > Ergo, you need a smarter newsreader. Try slrn.
    >


    Actually, if you count each tab as one character you are under 72 chars
    for each line. It was merely an illusion that you had more. My bad.

    --
    Andrew Poelstra
    http://www.wpsoftware.net/andrew
    Andrew Poelstra, Mar 10, 2010
    #11
  12. aydinh

    aydinh Guest

    On Mar 10, 1:56 pm, Andrew Poelstra <>
    wrote:
    > On 2010-03-10, Andrew Poelstra <> wrote:
    >
    > > On 2010-03-10, aydinh <> wrote:

    >
    > >>        char item;

    >
    > > Don't use tabs. Your lines are too long even without them. My newsreader
    > > will complain when I try to post this because I've quoted /your/ lines.
    > > Ergo, you need a smarter newsreader. Try slrn.

    >
    > Actually, if you count each tab as one character you are under 72 chars
    > for each line. It was merely an illusion that you had more. My bad.
    >
    > --
    > Andrew Poelstrahttp://www.wpsoftware.net/andrew


    I'm trying I only started programming 6 months ago for roughly 3 hours
    a week :(
    aydinh, Mar 10, 2010
    #12
  13. Re: Compiling error: expected identifier or ‘(’ before ‘{’ token

    Nick Keighley <> writes:

    > On 10 Mar, 13:21, aydinh <> wrote:
    >> On Mar 10, 1:04 pm, Nick Keighley <>
    >> > On 10 Mar, 12:51, aydinh <> wrote:

    <snip>
    >> > > typedef struct CalcParam { int item;
    >> > > struct calcParam * next;

    >>
    >> > I think you meant "struct CalcParam". Is this your actual code?

    >>
    >> > > } calcParam;

    <snip>
    >> the definition
    >> of struct calcParam is right, and yes it is my own code.

    >
    > must be me. I'd expect
    >
    > typedef struct CalcParam { int item;
    > struct CalcParam * next;
    > } calcParam;
    >
    > I'm surprised it can "see" calcParam when next is defined.


    I was at first, but I think the error is a subtle one.

    Lets re-write without relying on case as the sole difference between
    the names:

    typedef struct stag { int i; struct tdef *next; } tdef;

    The inner struct tdef defines a pointer to a new (incomplete) struct
    type with a struct tag that just happens to be the same as the typedef
    name that is being defined.

    The OP should get an error when attempting to do anything with the
    next pointer because it refers to an incomplete type. That is indeed
    what happens, but to get that far I had to correct a whole host of
    other syntax errors. I think the OP is just assuming it's correct
    because there was not error at the point of definition.

    To the OP: your definition of the struct is not correct and the
    compiler will tell about it eventually.

    <snip>
    --
    Ben.
    Ben Bacarisse, Mar 10, 2010
    #13
  14. Re:Re: Compiling error: expected identifier or ‘(’ before ‘{’ token

    On 2010-03-10, aydinh <> wrote:
    > On Mar 10, 1:56 pm, Andrew Poelstra <>
    > wrote:
    >> On 2010-03-10, Andrew Poelstra <> wrote:
    >>
    >> > On 2010-03-10, aydinh <> wrote:

    >>
    >> >>        char item;

    >>
    >> > Don't use tabs. Your lines are too long even without them. My newsreader
    >> > will complain when I try to post this because I've quoted /your/ lines.
    >> > Ergo, you need a smarter newsreader. Try slrn.

    >>
    >> Actually, if you count each tab as one character you are under 72 chars
    >> for each line. It was merely an illusion that you had more. My bad.
    >>

    >
    > I'm trying I only started programming 6 months ago for roughly 3 hours
    > a week :(


    In that case, I politely request that when posting code to Usenet,

    1. Don't use the tab key on your keyboard. The most consistent
    way that they display (assuming no servers on the chain delete
    them) is IMHO an ugly one.
    2. Don't use // comments. They wrap around and then your code
    can't be copy-pasted and still compile.

    Other than that you were netiquettically in the clear.

    --
    Andrew Poelstra
    http://www.wpsoftware.net/andrew
    Andrew Poelstra, Mar 10, 2010
    #14
  15. Re: Compiling error: expected identifier or '(' before '{' token

    aydinh <> writes:
    >> I'm surprised it can "see" calcParam when next is defined.

    >
    > I know what you mean, but this is how I've been shown to do it, and
    > both my reference books say to do it this way.


    The point is that "calcParam" and "CalcParam" are two different
    identifiers. If you spell them consistently:

    typedef struct calcParam { int item;
    struct calcParam * next;
    } calcParam;

    then you're ok.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Mar 10, 2010
    #15
  16. Re: Compiling error: expected identifier or ‘(’before ‘{’ token

    Andrew Poelstra <> writes:
    > On 2010-03-10, aydinh <> wrote:

    [...]
    >> I'm trying I only started programming 6 months ago for roughly 3 hours
    >> a week :(

    >
    > In that case, I politely request that when posting code to Usenet,
    >
    > 1. Don't use the tab key on your keyboard. The most consistent
    > way that they display (assuming no servers on the chain delete
    > them) is IMHO an ugly one.


    The problem isn't the tab key on the keyboard, it's the tab characters
    in the source. (In my editor with my configuration, pressing
    <tab> inserts spaces.)

    But yes, it's a good idea to avoid tab characters in code posted here.
    If you're on a Unix-like system, filtering the source through "expand"
    (or perhaps "expand -t 4") is a good solution.

    > 2. Don't use // comments. They wrap around and then your code
    > can't be copy-pasted and still compile.
    >
    > Other than that you were netiquettically in the clear.


    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Mar 10, 2010
    #16
  17. Re: Re: Compiling error: expected identifier or ‘(’ before ‘{’ token

    On 2010-03-11, Kenneth Brody <> wrote:
    > On 3/10/2010 8:38 AM, aydinh wrote:
    >>> I'm surprised it can "see" calcParam when next is defined.

    >>
    >> I know what you mean, but this is how I've been shown to do it, and
    >> both my reference books say to do it this way.

    >
    > You appear to have missed his point... You are defining a struct called
    > "CalcParam", whose "next" member points to a struct named "calcParam". Note
    > the different spellings. Now, perhaps you have two different structs with
    > the almost-identical names, but your code doesn't show any.
    >


    I read his code a couple of times and it looked to me like he
    was okay:

    typedef struct _test {
    int data1;
    int data2;
    struct _test *next;
    } Test;

    I added an underscore for clarity, but that was essentially
    his definition, wasn't it? (I've lost the original message.)

    --
    Andrew Poelstra
    http://www.wpsoftware.net/andrew
    Andrew Poelstra, Mar 11, 2010
    #17
  18. Re: Compiling error: expected identifier or ‘(’before ‘{’ token

    Andrew Poelstra <> writes:
    > On 2010-03-11, Kenneth Brody <> wrote:
    >> On 3/10/2010 8:38 AM, aydinh wrote:
    >>>> I'm surprised it can "see" calcParam when next is defined.
    >>>
    >>> I know what you mean, but this is how I've been shown to do it, and
    >>> both my reference books say to do it this way.

    >>
    >> You appear to have missed his point... You are defining a struct called
    >> "CalcParam", whose "next" member points to a struct named "calcParam". Note
    >> the different spellings. Now, perhaps you have two different structs with
    >> the almost-identical names, but your code doesn't show any.
    >>

    >
    > I read his code a couple of times and it looked to me like he
    > was okay:
    >
    > typedef struct _test {
    > int data1;
    > int data2;
    > struct _test *next;
    > } Test;
    >
    > I added an underscore for clarity, but that was essentially
    > his definition, wasn't it? (I've lost the original message.)


    No, he used two different names for the tag (and re-used one of those
    names for the typedef).

    Here's the declaration from the original post:

    typedef struct CalcParam { int item;
    struct calcParam * next;
    } calcParam;

    This is legal, but it creates a type "struct CalcParam" one of
    whose members is a pointer to an incomplete type "struct calcParam".

    (Note that using the same identifier for the struct tag and the
    typedef is perfectly ok. Or you can use a different name if you
    prefer, but you should pick some consistent convention.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Mar 11, 2010
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bubzilla
    Replies:
    2
    Views:
    923
    bubzilla
    Sep 25, 2006
  2. andrew browning
    Replies:
    16
    Views:
    15,474
    Artie Gold
    Mar 13, 2006
  3. =?Utf-8?B?Y2FzaGRlc2ttYWM=?=

    This is an unexpected token. The expected token is 'NAME'

    =?Utf-8?B?Y2FzaGRlc2ttYWM=?=, Jul 13, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    775
    =?Utf-8?B?Y2FzaGRlc2ttYWM=?=
    Jul 13, 2007
  4. Ram  Prasad
    Replies:
    21
    Views:
    2,856
    Kenneth Brody
    Jul 31, 2007
  5. ramif_47
    Replies:
    7
    Views:
    946
    ramif_47
    Nov 5, 2007
Loading...

Share This Page