PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : String-Variablen mit RP6?



RobotMichi
14.01.2010, 17:09
Hallo,

kann ich mit der Lib vom RP6 eigentlich Variablen als String verwenden? Wenn ich eine Variable als String vereinbare, schimpft der Compiler.

lg
Michi

KingTobi
14.01.2010, 17:11
Die Funktionen erwarten einen bestimmten Typ, man kann Typen ändern oder Variablen umwandeln.
Poste mal ein Beispiel, am besten mit Fehlermeldung.

RobotMichi
14.01.2010, 17:23
Der Programmcode:


#include "RP6ControlLib.h"


int main()
{
initRP6Control(void);
string s;
s="Hallo";
writeString(s);
return 0;
}

Und die Fehlermeldung:


> "E:\Daten\RP6\Programme\Eigene Programme\String\\make_all.bat"

E:\Daten\RP6\Programme\Eigene Programme\String>set LANG=C

E:\Daten\RP6\Programme\Eigene Programme\String>make all

-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: String.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=String.lst -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/String.o.d String.c -o String.o
String.c:1:29: error: RP6RobotBaseLib.h: No such file or directory
String.c:5: warning: function declaration isn't a prototype
String.c: In function 'main':
String.c:6: warning: implicit declaration of function 'initRP6RobotBase'
String.c:7: error: 'string' undeclared (first use in this function)
String.c:7: error: (Each undeclared identifier is reported only once
String.c:7: error: for each function it appears in.)
String.c:7: error: expected ';' before 's'
String.c:8: error: 's' undeclared (first use in this function)
String.c:9: warning: implicit declaration of function 'writeString'
String.c:11:3: warning: no newline at end of file
make: *** [String.o] Error 1

> Process Exit Code: 2
> Time Taken: 00:01

lg
Michi

KingTobi
14.01.2010, 17:27
Probleme fangen immer beim ersten Fehler an!

String.c:1:29: error: RP6RobotBaseLib.h: No such file or directory

RobotMichi
14.01.2010, 17:31
oje, da ist wohl ein Fehler im Makefile.

KingTobi
14.01.2010, 17:34
Du kannst zum testen auch den kompletten Pfad zu der Datei angeben.

RobotMichi
14.01.2010, 17:35
So, jetzt hab ich den Fehler beseitigt, die Fehlermeldung sieht nun so aus:


> "E:\Daten\RP6\Programme\Eigene Programme\String\\make_all.bat"

E:\Daten\RP6\Programme\Eigene Programme\String>set LANG=C

E:\Daten\RP6\Programme\Eigene Programme\String>make all

-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: String.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=String.lst -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/String.o.d String.c -o String.o
String.c: In function 'main':
String.c:7: error: 'string' undeclared (first use in this function)
String.c:7: error: (Each undeclared identifier is reported only once
String.c:7: error: for each function it appears in.)
String.c:7: error: expected ';' before 's'
String.c:8: error: 's' undeclared (first use in this function)
String.c:11:3: warning: no newline at end of file
make: *** [String.o] Error 1

> Process Exit Code: 2
> Time Taken: 00:01

KingTobi
14.01.2010, 17:39
Ja er kennt den Datentyp "string" nicht, wie soll er auch.

RobotMichi
14.01.2010, 18:00
schade, trotzdem danke für die Hilfe

lg
Michi

KingTobi
14.01.2010, 18:04
Versuchs so:


#include "RP6ControlLib.h"


int main()
{
initRP6Control(void);
char s[6]="Hallo";
writeString(s);
return 0;
}