
Код
// test.h
#ifndef _TEST_H_
#define _TEST_H_
#include <inttypes.h>
enum enButtons { btNone, btUp, btDown, btLeft, btRight, btEnter, btExit };
typedef void (*DispFuncPtr)(enum enButtons btn);
extern DispFuncPtr* DispFunc;
extern void TestFunc1(enum enButtons btn);
extern void TestFunc2(enum enButtons btn);
#endif
#ifndef _TEST_H_
#define _TEST_H_
#include <inttypes.h>
enum enButtons { btNone, btUp, btDown, btLeft, btRight, btEnter, btExit };
typedef void (*DispFuncPtr)(enum enButtons btn);
extern DispFuncPtr* DispFunc;
extern void TestFunc1(enum enButtons btn);
extern void TestFunc2(enum enButtons btn);
#endif
Код
//test.c
#include "test.h"
DispFuncPtr* DispFunc = (void*)0;
void TestFunc1(enum enButtons _btn)
{
}
void TestFunc2(enum enButtons _btn)
{
}
#include "test.h"
DispFuncPtr* DispFunc = (void*)0;
void TestFunc1(enum enButtons _btn)
{
}
void TestFunc2(enum enButtons _btn)
{
}
Код
//main.c
#include <inttypes.h>
#include "test.h"
int main(void)
{
enum enButtons x;
DispFunc = (DispFuncPtr*)&TestFunc1;
x = btUp;
(*DispFunc)(x);
while(1){};
}
#include <inttypes.h>
#include "test.h"
int main(void)
{
enum enButtons x;
DispFunc = (DispFuncPtr*)&TestFunc1;
x = btUp;
(*DispFunc)(x);
while(1){};
}
Результат:
Код
Build started 13.4.2008 at 01:31:32
avr-gcc.exe -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=4000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT test.o -MF dep/test.o.d -c ../test.c
avr-gcc.exe -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=4000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s: Assembler messages:
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s:35: Error: garbage at end of line
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s:36: Error: missing ')'
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s:36: Error: garbage at end of line
make: *** [main.o] Error 1
Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=4000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT test.o -MF dep/test.o.d -c ../test.c
avr-gcc.exe -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=4000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s: Assembler messages:
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s:35: Error: garbage at end of line
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s:36: Error: missing ')'
C:\DOCUME~1\Pawel\LOCALS~1\Temp/ccKMaaaa.s:36: Error: garbage at end of line
make: *** [main.o] Error 1
Build succeeded with 0 Warnings...
Раньше что то типа этого проходило. Что у меня не так?