View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
Function pointer in a structure makes a compiler mess-SOLVED |
Posted: Sun Dec 13, 2015 11:58 am |
|
|
Hi,
Compiler 5.025
This is unacceptable:
Code: | struct process
{
unsigned char* name;
int (*func)(void);
int8 called;
struct process* p_process;
}process_riko; |
When I remove int (*func)(void); everything works. _________________ A person who never made a mistake never tried anything new.
Last edited by rikotech8 on Tue Dec 15, 2015 1:11 am; edited 1 time in total |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1358
|
|
Posted: Sun Dec 13, 2015 12:23 pm |
|
|
try typedef'ing the function pointer type first:
Code: |
typedef int (*func_type)(void);
struct process
{
unsigned char* name;
func_type func;
int8 called;
struct process* p_process;
}process_riko;
|
Also keep in mind, I think there was a version 5 change somewhere that corrected how function pointers worked. I don't remember how far back that was though. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 13, 2015 12:53 pm |
|
|
In addition to the typedefing, your version of the compiler also has the
bug listed in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=54461
Which can be fixed like this:
Code: |
typedef int (*func_type)(void);
struct process
{
unsigned char* name;
func_type func;
int16 dummy; // *** Added to fix bug in link
int8 called;
struct process* p_process;
}process_riko;
|
This bug was fixed in compiler vs. 5.051. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Tue Dec 15, 2015 1:10 am |
|
|
Thank you guys. It works with typedef. I hope CCS will fix that problem in the future versions. _________________ A person who never made a mistake never tried anything new. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1358
|
|
Posted: Tue Dec 15, 2015 7:47 am |
|
|
rikotech8 wrote: | Thank you guys. It works with typedef. I hope CCS will fix that problem in the future versions. |
Make sure to email them a bug report so they will hopefully be able to fix that. |
|
|
|