Go Down

Topic: strtok problem (Read 3124 times) previous topic - next topic

jeffob

i am trying to switch my project over to arduino v18 linux from v18 mac
when i try to compile i get an error with strtok

error: 'strtok' was not declared in this scope

any help is greatly appreciated

Thanks
Jeff

Coding Badly


Add this to the top of your Sketch...

#include <string.h>

jeffob

i tried that first, but no go.

seems like something else is messed up...

Coding Badly


Being unfamiliar with Linux, I can't think of any more suggestions.  Hopefully, someone else can offer something.

cr0sh

can we see your sketch/code?
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

jeffob

here is the one function that uses strtok
just a reminder that this code has been working for months under Mac OS X arduino v18

Code: [Select]
void parseCommand(char * inStr)
{
 byte i = 0;
 char * pch;

 argv[0][0] = '\0';
 argv[1][0] = '\0';
 argv[2][0] = '\0';
 argv[3][0] = '\0';
 argv[4][0] = '\0';
 argv[5][0] = '\0';
 if (inStr[0] == '\0') return;

 pch = strtok (inStr," ");
 while (pch != NULL)
 {
   strcpy(argv[i], pch);
   i++;

   if (i < 6)
     pch = strtok (NULL, " ");
   else
     pch = NULL;
 }
 argc = i;
}

cr0sh

Maybe this thread might help...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231961642
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

jeffob

thanks for the link.
i realize after doing some reading that strtok is probably not a good idea. i guess i'm just curious now why my code compiles on mac but not on linux.
i'm guessing that arduino is using two different versions of gcc. i was just hoping that somebody might be able to confirm and or explain the difference between arduino for linux and arduino for mac.

Thanks
Jeff

PaulS

Quote
i'm guessing that arduino is using two different versions of gcc.


The Arduino IDE invokes whichever version of avr-gcc is installed on the computer.

There are versions of avr-gcc for the Mac, for all the flavors of Windows (XP, Vista, Seven, 32 bit and 64 bit) and for all the flavors of Linux (32 bit and 64 bit).

There are current versions and older versions of avr-gcc for each of the platforms.

As you've discovered, they are not all compatible.

Go Up