CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Function pointer in a structure makes a compiler mess-SOLVED

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

Function pointer in a structure makes a compiler mess-SOLVED
PostPosted: Sun Dec 13, 2015 11:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Dec 13, 2015 12:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Dec 13, 2015 12:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 15, 2015 1:10 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 15, 2015 7:47 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group