Compiler error when casting to function pointer
Posted
by detly
on Stack Overflow
See other posts from Stack Overflow
or by detly
Published on 2010-04-19T07:26:13Z
Indexed on
2010/04/19
7:33 UTC
Read the original article
Hit count: 280
I'm writing a bootloader for the PIC32MX, using HiTech's PICC32 compiler (similar to C90). At some point I need to jump to the real main routine, so somewhere in the bootloader I have
void (*user_main) (void);
user_main = (void (*) (void)) 0x9D003000;
user_main();
(Note that in the actual code, the function signature is typedef'd and the address is a macro.)
I would rather calculate that (virtual) address from the physical address, and have something like:
void (*user_main) (void);
user_main = (void (*) (void)) (0x1D003000 | 0x80000000);
user_main();
...but when I try that I get a compiler error:
Error #474: ; 0: no psect specified for function variable/argument allocation
Have I tripped over some vagarity of C syntax here?
This error doesn't reference any particular line, but if I comment out the user_main()
call, it goes away. (This might be the compiler removing a redundant code branch, but the HiTech PICC32 isn't particularly smart in Lite mode, so maybe not.)
© Stack Overflow or respective owner