Pages: [1]   Go Down
Author Topic: strtok problem  (Read 2710 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 199
Posts: 12768
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Add this to the top of your Sketch...

#include <string.h>
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i tried that first, but no go.

seems like something else is messed up...
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 199
Posts: 12768
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

can we see your sketch/code?
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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;
}
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe this thread might help...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231961642
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: