C function prototypes in CVAVR 1.23.1

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I generated a codevision project that generates an interesting error resulting from a prototype formulation.

Here is the situation.
I have a main.c file that requires the use of a "MyFunction()" residing in a seperate file function.c. The function MyFunction utilizes a #define statement that is inside function.h. In addition to this #define statement, function.h also contains the protoype for "MyFunction()". So "function.c" contains the line "#include function.h". Since main.c needs to call "MyFunction()" it also contains the line "#include function.h". I get some interesting results dependin on the syntax of my prototype.

If I use:
int MyFunction(signed char);
This generates an illegal symbol error n the header file this line resides in.

whereas if I use:
int MyFunction(signed char anything);

where "anything" does not even need to be the same variable name used in the actual function declaration
This will compile without errors.

Both these prototypes are inside "function.h" to test this I just commented out one at a time.

So the question is:

Is this correct behavior or is this a bug? Nearest I can tell from my C books and local colleagues, both prototypes should compile without any errors. Its just a matter of form/style. I actually had an acquaintence with the IAR compiler get both to compile without error.

What are this forum's thoughts on this?

I attached the files if anyone wants to try to check this phenomenon out. If you want to try with another compiler just disregard the .prj file and create a new project with your compiler.

Regards,

Erick

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for fixing that Pavel! Wow that was quick!

Erick