Double pointer as parameter doesn't work with typedef

I am trying to pass a pointer by reference to a function and get that function to point my pointer at a structure that it finds.

char get_structure(STRUCTURE **ptr)
{
    if(foundstructure)
    {
        *ptr = &theStructure;
        return 1;
    }
    return 0;
}


This works how I expect it, but when I try and declare the function prototype in the header file:

char get_structure(STRUCTURE **ptr);


I always get a compiler error:

error C141: syntax error near '*', expected ')'


I don't get an error when this is a defined type like char, int or long, but I get the error when this is a pointer to a typedef that I have defined.

How can I declare this in my header file without an error?

Nathan

Parents
  • am trying to pass a pointer by reference to a function and get that function to point my pointer at a structure that it finds.

    char get_structure(STRUCTURE **ptr)

    are you one of those "C is C whatever it runs on" types?

    if you look at the C51 assembler the above will generate, you will realize that "C is C whatever it runs on" is a very bad mantra when working with this architecture. There is absolutely nothing wrong with programming the '51 in C (I have, probably, written 100,000 lines of it) but do think of the architecture when designing the code.

    Erik

Reply
  • am trying to pass a pointer by reference to a function and get that function to point my pointer at a structure that it finds.

    char get_structure(STRUCTURE **ptr)

    are you one of those "C is C whatever it runs on" types?

    if you look at the C51 assembler the above will generate, you will realize that "C is C whatever it runs on" is a very bad mantra when working with this architecture. There is absolutely nothing wrong with programming the '51 in C (I have, probably, written 100,000 lines of it) but do think of the architecture when designing the code.

    Erik

Children
No data
More questions in this forum