From: SourceForge.net <no...@so...> - 2003-10-07 07:29:31
|
Bugs item #818483, was opened at 2003-10-06 09:49 Message generated for change (Comment added) made by bernhardheld You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=818483&group_id=599 Category: msc51(8051) target Group: non bugs Status: Closed Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Bernhard Held (bernhardheld) Summary: Passing parameters when calling a function throuh a pointer Initial Comment: The code: // File eg.c int (* pFunction)(int); // Pointer to a function extern int g; void Function(int i) // The function to be called { g = g + i; } void Example(void) { // The asignement of the function pointer pFunction = Function; // The call that can be compiled but... what // about the parameter the function waits for? pFunction; // The desired call to a function through a // pointer that cannot be compiled pFunction(1); // Line 20 } // End of file Cannot be compiled with the command 'sdcc -c eg.c' because of 'too many parameters error' at line 20. I tried the 2.3.5 version. Snapshots Oct 3 2003 and Apr 21 2003. My email address: Joa...@ya... I hope this report can help to improve the already excellent sdcc. Thank you, Joan Martinez ---------------------------------------------------------------------- >Comment By: Bernhard Held (bernhardheld) Date: 2003-10-07 09:29 Message: Logged In: YES user_id=203539 SDCC doesn't build a call tree. The overlay feature in SDCC is much simpler than e.g. in Keil's compiler. It's well explained in our Fine manual: http://sdcc.sourceforge.net/doc/sdccman.html/node26.html ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2003-10-07 08:55 Message: Logged In: NO I was assuming that the compiler could not build up the function call tree. (Looses track which function is (or may be) called by the function pointer). So if there are two functions f and fp (which would both use overlayed variables) and f calls fp by a function pointer then fp could change variables which belong to f? Frieder ---------------------------------------------------------------------- Comment By: Bernhard Held (bernhardheld) Date: 2003-10-06 21:59 Message: Logged In: YES user_id=203539 I don't know of any reason, why functions, which are called via pointers, should be used with nooverlay. ---------------------------------------------------------------------- Comment By: Frieder Ferlemann (frief) Date: 2003-10-06 11:57 Message: Logged In: YES user_id=589052 ... and those not having a parameter should be used with the pragma nooverlay (when they do not have the reentrant keyword). Is that correct? ---------------------------------------------------------------------- Comment By: Bernhard Held (bernhardheld) Date: 2003-10-06 10:11 Message: Logged In: YES user_id=203539 Functions, which take parameters and are called via pointer must be reentrant: int (* pFunction)(int) reentrant; void Function(int i) reentrant { g = g + i; } http://sdcc.sourceforge.net/doc/sdccman.html/node64.html (*pFunction)(1); ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=818483&group_id=599 |