GCC Function Declaration Warning

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

Hi all,

I have got the following warning for the following piece of code (indirect call to a function):

warning: function declaration isn't a prototype

(*(void (*)())temp_Function)(temp_Index,temp_Token);

How can I declare this indirect function call for the warning to disappear?

Thanks

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

Wow that cast makes that close to unreadable! For function pointer declarations personally I'd always use a typedef which has the advantage of (a) making a reusable type that can easily be used in a cast wherever need and (b) keeps the function interface defined in just one place so that when you decide to add a third parameter you just need to change it in one place.

typedef void (*fptr_type)(idx_type, tok_type);

then later:

fptr_type fptr = (fptr_type) 0x1234;
fptr(idx_value, tok_value);