Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:16:51+00:00 2026-06-17T20:16:51+00:00

i am getting a compiler warning, here’s the code: uint8 executeSpecialCommand(const char *string) {

  • 0

i am getting a compiler warning, here’s the code:

uint8 executeSpecialCommand(const char *string)
{
    char *parameters;           
    parameters = strtok(string, "=");

    if (parameters)
     {
         usbSendf("\nProcessing Parameters...");       
         while(parameters != NULL)
         {
             parameters = strtok(NULL, " ");
             usbSendf("\n%s", parameters);
         }
         return 1;
     }
    else
        return 0;   
}

the error points to line 3 and i think it is because “=”. strtok is expecting a const char* somehow in other parts of the code i use the same and i get no warning. An ideas here to help educate me ?

UPDATE
The error i get is:

warning 196: pointer target lost const qualifier

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:16:52+00:00Added an answer on June 17, 2026 at 8:16 pm

    The strtok function modifies its first argument. From a man page:

    BUGS
    Be cautious when using these functions. If you do use them, note that:

       * These functions modify their first argument.
    
       * These functions cannot be used on constant strings.
    

    This means that you can pass a const char* as the first argument as you are doing with the variable named string.

    strtok works by inserting a NULL in the passed string at every delimeter which allows it to return each token without allocating memory for the returned string. I doubt whether SDCC supports the reentrant version strtok_r but it would be possible to use that instead if it existed.

    Alternatively, create your own copy of the incoming string before parsing. If you know the maximum incoming string size then the string copy can be allocated on the stack at the top of your parsing function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a compiler warning for the @SuppressWarnings annotation in eclipse for the code:
I'm getting a compiler warning when using the following code: for(int i=0; i<[mutableTempArray count];
I am getting this compiler (gcc 4.5) warning: Formatter.cpp:23: warning: unknown conversion type character
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
When trying to compile the following code, I am getting a warning that line
I am getting the following Compiler Warning: 'Resources.Foo.GetType()' hides inherited member 'object.GetType()'. Use the
I'm getting a warning for the following code, which dissapears if I remove boost::blank
I'm simply trying to overload a + operator and I'm getting this compiler warning
So, (seemingly) out of the blue, my project starts getting compiler warning 1685: The
i am getting the following warning when i compile in C. ../tcpuip/uip_arp.c: In function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.