Forum: Mikrocontroller und Digitale Elektronik rfm12lib lässt sich nicht coimpilieren


von Michael W. (michel72)


Lesenswert?

Hallo ,

ich versuche in Codeblock 10.5 mit dem avr-gcc 4.3.2 die RFM12lib 
(http://www.das-labor.org/wiki/RFM12_library) zu compilieren und bekomme 
bei folgender Zeile :
1
//non-inlined version of rfm12_data
2
//warning: without the attribute, gcc will inline this even if -Os is set
3
//non-inlined version of rfm12_data
4
//warning: without the attribute, gcc will inline this even if -Os is set
5
void __attribute__ ((noinline)) rfm12_data(uint16_t d)
6
{
7
  SS_ASSERT();
8
  #if !(RFM12_SPI_SOFTWARE)
9
  SPDR = d>>8;
10
  while(!(SPSR & (1<<SPIF)));
11
12
  SPDR = d & 0xff;
13
  while(!(SPSR & (1<<SPIF)));
14
15
  #else
16
  spi_data(d >> 8   );
17
  spi_data(d &  0xff);
18
  #endif
19
  SS_RELEASE();
20
}
21
22
23
//non-inlined version of rfm12_read
24
//warning: without the attribute, gcc will inline this even if -Os is set
25
uint16_t __attribute__ ((noinline)) rfm12_read(uint16_t c)
26
{
27
  uint16_t retval;
28
  SS_ASSERT();
29
30
  #if !(RFM12_SPI_SOFTWARE)
31
  SPDR = c>>8;
32
  while(!(SPSR & (1<<SPIF)));
33
  retval = SPDR<<8;
34
  SPDR = c & 0xff;
35
  while(!(SPSR & (1<<SPIF)));
36
  retval |= SPDR;
37
38
  #else
39
  retval =  spi_data(c >> 8   );
40
  retval <<= 8;
41
  retval |= spi_data(c &  0xff);
42
  #endif
43
  SS_RELEASE();
44
  return retval;
45
}

diesen Fehler :
Zeile 59 und 79 sind jeweils die Function Header.

Hat Jemand eine Idee ? Ich habe es natürlich auch schon ohne :
_attribute_ ((noinline))
probiert ohne Erfolg.



..\Utils\RFM12lib\include\rfm12_spi.c|59|error: expected ')' before 'd'|

..\Utils\RFM12lib\include\rfm12_spi.c|79|warning: data definition has no 
type or storage class|
..\Utils\RFM12lib\include\rfm12_spi.c|79|warning: type defaults to 'int' 
in declaration of 'uint16_t'|
..\Utils\RFM12lib\include\rfm12_spi.c|79|warning: 'noinline' attribute 
ignored|
..\Utils\RFM12lib\include\rfm12_spi.c|79|error: expected ',' or ';' 
before 'rfm12_read'|

von Bernhard M. (boregard)


Lesenswert?

Hi,

ich vermute mal, das hat nichts mit dem attribute zu tun, der Compiler 
kennt 'uint16_t' nicht, sind die <stdint.h> eingebunden?

Gruß,
Bernhard

P.S.: Ich hasse s, wenn *.c files per include eingebunden werden, das 
ist schlechter Programmierstil!

von Michael W. (Gast)


Lesenswert?

Hallo Bernhard,

danke für den Tipp, werde ich heute Abend gleich mal testen.
Bin jetzt kein C - Crack , aber das die .C includiert wird ist wohl dem 
Umstand zu verdanken, dass diese Lib 2 Wrapper Dateien benötigt.

Gruß
Michael

von Bernhard M. (boregard)


Lesenswert?

...ist ja nicht Deine Schuld... man macht sowas meiner Meinung nicht, 
und es geht auch anders...
Ich vermute, das hat manchmal mit Optimierungen zu tun. Wenn man die 
inkludiert, dann kann der Linker unbenutzte Funktionen rausschmeissen. 
Wenn man das anders erreichen will muß man halt Libraries so bauen, wie 
das unter Unix üblich ist...

Aber wie gesagt, ich denke der Compiler kennt die C99 uintxx_t Typen 
nicht...also gcc mit '-std=c99' aufrufen oder <stdint.h> einbinden...

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.