Page 1 of 1

undefined symbol: strnicmp

Posted: Fri Aug 16, 2024 7:08 am
by Quin
I'm trying to link against a library built with Visual Studio 2022 in my PB app. I had to import a couple libraries like ole32 and version.lib, but the only import I can't figure out is strnicmp. According to microsoft, this is an old and not supported alias to _strnicmp. I tried:

Code: Select all

	Import "ucrt.lib"
strnicmp(String1$, String2$, Count)
EndImport
and many other variations, including trying to import the underscore version as the non-underscore name, but none of them fixed it. Has anyone successfully done this?
Thanks.

Re: undefined symbol: strnicmp

Posted: Fri Aug 16, 2024 7:28 am
by infratec
This works in PB 6.11 x86 on Windows 10 x64

Code: Select all

ImportC "oldnames.lib"
  strnicmp.i(String1.p-Ascii, String2.p-Ascii, Count)
EndImport


Debug strnicmp("abcx213e12", "ABCY9789", 2)
Debug strnicmp("abcx213e12", "ABCY9789", 5)
Debug strnicmp("bbcx213e12", "ABCY9789", 1)

Re: undefined symbol: strnicmp

Posted: Fri Aug 16, 2024 7:36 am
by Quin
Infratec,
This worked perfectly, thanks for the help!

Re: undefined symbol: strnicmp

Posted: Fri Aug 16, 2024 7:56 am
by Fred
It should work without oldnames:

Code: Select all

ImportC "ucrt.lib"
  CompilerIf #PB_Compiler_32Bit
    strnicmp(String1.p-utf8, String2.p-utf8, Count) As "__strnicmp"
  CompilerElse
    strnicmp(String1.p-utf8, String2.p-utf8, Count) As "_strnicmp"
  CompilerEndIf
EndImport


Debug strnicmp("abcx213e12", "ABCY9789", 2)
Debug strnicmp("abcx213e12", "ABCY9789", 5)
Debug strnicmp("bbcx213e12", "ABCY9789", 1)
Note: why not using _strnicmp directly (if it's only a name issue, you can use a macro to map it) ?

Code: Select all

ImportC "ucrt.lib"
  _strnicmp(String1.p-utf8, String2.p-utf8, Count)
EndImport

Macro strnicmp(a,b,c) : _strnicmp(a,b,c) : EndMacro


Debug strnicmp("abcx213e12", "ABCY9789", 2)
Debug strnicmp("abcx213e12", "ABCY9789", 5)
Debug strnicmp("bbcx213e12", "ABCY9789", 1)

Re: undefined symbol: strnicmp

Posted: Fri Aug 16, 2024 3:01 pm
by Quin
@Fred, ucrt.lib with a Macro works perfectly. Thanks so much!