stricmp() missing or moved in Arduino 1.8.2?

Status
Not open for further replies.

bboyes

Well-known member
:confused:
Large application compiles and runs in Arduino 1.8.1 and TD 1.35.
Compile fails in 1.8.2 and TD 1.36, on this source:
Code:
if (!stricmp (read_buf, header_str_ptr))		// is this the section header?
			return line_num;
With this error:
Code:
SALT_settings.cpp:625:41: error: 'stricmp' was not declared in this scope
   if (!stricmp (read_buf, header_str_ptr))  // is this the section header?

Googling didn't find any help (are we the first to notice this?), but did find this Stackoverflow discussion of why stricmp should not be used.

So I guess we can recode to use strcasecmp() but at the least I wonder what is different about string libraries in 1.8.2?
No mention here: https://www.arduino.cc/en/Main/ReleaseNotes

This module's .h file just has
Code:
#include <arduino.h>
adding #include <string.h> does not help.
 
1.36 updated the toolchain and C library. We also lost powf along the way.

I've put this on my list of bugs to fix for 1.37.

In the meantime, for a quick workaround:

Code:
#define stricmp(a, b) strcasecmp(a, b)

//does not work  :(
//extern "C" int stricmp(const char *s1, const char *s2);

void setup() {
}

void loop() {
  const char *s1 = "test1";
  const char *s2 = "TEST1";
  int i = stricmp(s1, s2);
  Serial.println(i);
  delay(1000);
}
 
This workaround doesn't seem to work for me:

Although I put extern "C" float pow2f(float);
in my sketch, I still can't compile
/Users/thierryfrenkel/Documents/sloeber-workspace/dVoxCore/Release/../dVoxCore.ino:18: undefined reference to `pow2f'
 
I tried this just now.

Code:
extern "C" float pow10f(float);

void setup() {
  while (!Serial) ;
  Serial.print("10^4 = ");
  Serial.println(pow10f(4));
  Serial.print("10^0.25 = ");
  Serial.println(pow10f(0.25));
}

void loop() {
}

It compiles and prints:

Code:
10^4 = 10000.00
10^0.25 = 1.78
 
For what it is worth I did a complete search through my Arduino 1.8.2 with current Teensyduino for pow2f and there were no hits. It did find powf and pow10f...
 
Oh, pow2f (not 10). Has this ever worked? It doesn't work when I do a quick test compile on Linux with gcc, even with math.h and -lm on the command line.

Code:
test.c: In function ‘main’:
test.c:5:2: warning: implicit declaration of function ‘pow2f’ [-Wimplicit-function-declaration]
  float x = pow2f(0.2);
  ^
test.c:5:8: warning: unused variable ‘x’ [-Wunused-variable]
  float x = pow2f(0.2);
        ^
test.c:7:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/tmp/ccmVwQEh.o: In function `main':
test.c:(.text+0x21): undefined reference to `pow2f'
collect2: error: ld returned 1 exit status
 
Good question, don't remember if I used pow2f() already in my code before updating to 1.36. Would it be helpful if I switch (temporarily) back to 1.35 to test it, or is there anyone who hasn't yet upgraded and could do the test.

pow2f and log2f are essential functions if you write music related software for the Teensy 3.6...
 
log2f definitely works. So does powf, so you can use powf(2.0, x) to compute 2 to the power of x.

That's what I'm actually doing as a workaround: powf(2.0, x). But I thought and hoped that a pow2f function, similar to the log2f function would use less CPU cycles since we are already almost in the binary domain with this. I remember having read something about that, some time ago. But I'm perhaps completely wrong with my ideas...
 
Status
Not open for further replies.
Back
Top