|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
passing pointers to functionsI have been having difficulty passing a function pointer in a function call. In
researching the issue, it appears that there is a compiler issue with doing that & I've tried a couple of suggested fixes with no luck. Since the version appears to required in order to get the correct fix, my version is gcc-4.3.0. This is my last attempt. 1. Here is the function prototype in the .h file void InsertTask(ptr2func TaskPtr); // line 42 in atm328.h 2. Here is the code in the single .c file containing all the code related to this issue. typedef void (*ptr2func)(void); Here is the function void InsertTask(ptr2func TaskPtr) Here is the call InsertTask(LEDTask); 3. Here is the returned error. ../atm328.h:42: error: expected ')' before 'TaskPtr' Before I try updating avr gcc, is there something else that I need to do in order to make this work? thanks. _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@... http://lists.nongnu.org/mailman/listinfo/avr-gcc-list |
|
|
Re: passing pointers to functionsIt may be because ptr2func is not declared before the prototype. Try putting the typedef of ptr2func in the header file above the prototypes.
--John On Sat, Nov 7, 2009 at 12:07 PM, don clay <donclay@...> wrote: I have been having difficulty passing a function pointer in a function call. In _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@... http://lists.nongnu.org/mailman/listinfo/avr-gcc-list |
|
|
RE: passing pointers to functionsTwo things: 1. IIRC, there was a problem with 4.3.0 unless you had the right patches. It may not be related to your problem, but we need to know what platform you're building on, and what patches are you using. You may need to upgrade. 2. We need to have a compilable test case, preferably as small as possible, that shows the error. There is not enough information here to tell you one way or the other what is going on with your code. Honestly I suspect something in your code, and not the compiler. > -----Original Message----- > From: > avr-gcc-list-bounces+eric.weddington=atmel.com@... > [mailto:avr-gcc-list-bounces+eric.weddington=atmel.com@nongnu. > org] On Behalf Of don clay > Sent: Saturday, November 07, 2009 1:08 PM > To: avr-gcc-list@... > Subject: [avr-gcc-list] passing pointers to functions > > I have been having difficulty passing a function pointer in a > function call. In > researching the issue, it appears that there is a compiler > issue with doing that & > I've tried a couple of suggested fixes with no luck. > > Since the version appears to required in order to get the > correct fix, my version > is gcc-4.3.0. > > This is my last attempt. > > 1. Here is the function prototype in the .h file > > void InsertTask(ptr2func TaskPtr); // line > 42 in atm328.h > > 2. Here is the code in the single .c file containing all the > code related to this > issue. > > typedef void (*ptr2func)(void); > > Here is the function > > void InsertTask(ptr2func TaskPtr) > > Here is the call > > InsertTask(LEDTask); > > > 3. Here is the returned error. > > ../atm328.h:42: error: expected ')' before 'TaskPtr' > > > Before I try updating avr gcc, is there something else that I > need to do in order > to make this work? > > thanks. > > > > _______________________________________________ > AVR-GCC-list mailing list > AVR-GCC-list@... > http://lists.nongnu.org/mailman/listinfo/avr-gcc-list > _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@... http://lists.nongnu.org/mailman/listinfo/avr-gcc-list |
| Free embeddable forum powered by Nabble | Forum Help |