|
01-30-2017, 01:19 PM
|
#1
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
Xcode and std::stof
Hello,
I'm having a very annoying issue in Xcode7.
I use in my c++ code the std::stof() function. It works fine on Windows VisualStudio but on macOS Xcode it states that stof() is not a member function of std::
I use Clang 1.0 as a compiler.
Anyone has a hint please? I would like to continue using stof() in my code...
Thank you in advance,
|
|
|
01-30-2017, 01:24 PM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
I use Clang 1.0 as a compiler.
|
Wow! How old is that?!
std::stof is a C++11 standard library function which your compiler might not support at all. If it however does support C++11, you will need to enable it separately in your build settings. Newer Visual Studio versions (since VS2010) have C++11 always enabled.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-30-2017, 01:34 PM
|
#3
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
Quote:
Originally Posted by Xenakios
Wow! How old is that?!
std::stof is a C++11 standard library function which your compiler might not support at all. If it however does support C++11, you will need to enable it separately in your build settings. Newer Visual Studio versions (since VS2010) have C++11 always enabled.
|
Thank you for your feedback, I use that compiler because it is recommended for use with WDL-OL as far as I know (Martin Finke's blog) :
COMPILER = com.apple.compilers.llvm.clang.1_0
Or maybe it is ok to use a different one ?
For example : COMPILER = com.apple.compilers.gcc.4_2
Any hint, suggestion, explanation is welcome, I'm relatively newbe to cross-platform wdl development
|
|
|
01-30-2017, 01:45 PM
|
#4
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
Thank you for your feedback, I use that compiler because it is recommended for use with WDL-OL as far as I know (Martin Finke's blog) :
COMPILER = com.apple.compilers.llvm.clang.1_0
Or maybe it is ok to use a different one ?
For example : COMPILER = com.apple.compilers.gcc.4_2
Any hint, suggestion, explanation is welcome, I'm relatively newbe to cross-platform wdl development
|
Definitely not gcc, that's no longer supported by Apple. Anyway, I suppose XCode should use the latest installed Clang/LLVM compiler anyway. (I don't remember what the Clang versions were back in XCode 7, I am using XCode 8.2 myself currently.) You will however need to separately enable C++11 if you want to use the language features or the library from that.
What macOS versions does your code need to support? The C++11 standard library can't be used for building for older versions than macOS 10.7.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-30-2017, 01:56 PM
|
#5
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
I put the target to sdk 10.5 , but I think I can change it to 10.7 if needed to enable c++11 support.
New versions of LLVM compilers come embedded with new versions of Xcode or I need to intall it separately?
|
|
|
01-30-2017, 02:05 PM
|
#6
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
I put the target to sdk 10.5 , but I think I can change it to 10.7 if needed to enable c++11 support.
New versions of LLVM compilers come embedded with new versions of Xcode or I need to intall it separately?
|
Clang/LLVM is the official compiler for XCode and comes installed with it. Note that besides changing the target sdk and OS version for deployment, you will need to change C++ language dialect and the used standard library versions too.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-30-2017, 02:12 PM
|
#7
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
Quote:
Originally Posted by Xenakios
Clang/LLVM is the official compiler for XCode and comes installed with it. Note that besides changing the target sdk and OS version for deployment, you will need to change C++ language dialect and the used standard library versions too.
|
Ok. If I set both to 10.7 and in the same "common.xcconfig" file I enable :
CLANG_CXX_LANGUAGE_STANDARD = c++0x
CLANG_CXX_LIBRARY = libc++
Will this be sufficient to enable c++11 and consequently std::stof ?
|
|
|
01-30-2017, 02:56 PM
|
#8
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
Ok. If I set both to 10.7 and in the same "common.xcconfig" file I enable :
CLANG_CXX_LANGUAGE_STANDARD = c++0x
CLANG_CXX_LIBRARY = libc++
Will this be sufficient to enable c++11 and consequently std::stof ?
|
CLANG_CXX_LANGUAGE_STANDARD = c++0x should probably be CLANG_CXX_LANGUAGE_STANDARD = c++11 instead. c++0x used to work but might now be obsolete.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-30-2017, 11:41 PM
|
#9
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
Quote:
Originally Posted by Xenakios
CLANG_CXX_LANGUAGE_STANDARD = c++0x should probably be CLANG_CXX_LANGUAGE_STANDARD = c++11 instead. c++0x used to work but might now be obsolete.
|
Thank you so much Xenakios for your help !
Just one thing, in addition to :
sdk = 10.7
base sdk = 10.7
CLANG_CXX_LANGUAGE_STANDARD = c++0x / c++11
CLANG_CXX_LIBRARY = libc++
...and MANTAINING : COMPILER = com.apple.compilers.llvm.clang.1_0
Are there other things to change/add ?
Changing this stuff cause some error messages during compiling?
You used the same method/workaround to enable c++11 (if you have it enabled)?
Thank you
|
|
|
01-31-2017, 12:08 AM
|
#10
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
Thank you so much Xenakios for your help !
Just one thing, in addition to :
sdk = 10.7
base sdk = 10.7
CLANG_CXX_LANGUAGE_STANDARD = c++0x / c++11
CLANG_CXX_LIBRARY = libc++
...and MANTAINING : COMPILER = com.apple.compilers.llvm.clang.1_0
Are there other things to change/add ?
Changing this stuff cause some error messages during compiling?
You used the same method/workaround to enable c++11 (if you have it enabled)?
Thank you
|
I've set the stuff in the XCode GUI, so I am not 100% sure how everything should be set up with the text files. What errors are you getting? Did you drop the compiler line? Maybe that makes it use the latest compiler...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-31-2017, 01:24 PM
|
#11
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
Quote:
Originally Posted by Xenakios
I've set the stuff in the XCode GUI, so I am not 100% sure how everything should be set up with the text files. What errors are you getting? Did you drop the compiler line? Maybe that makes it use the latest compiler...
|
>What errors are you getting?
I didn't try that procedure yet, currently I'm away, so I was just asking if that change could cause some incompatibilities when compiling. The only error I had before was the missing std::stof function, because with sdk 10.5 c++11 is not supported...
|
|
|
01-31-2017, 02:00 PM
|
#12
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
>What errors are you getting?
I didn't try that procedure yet, currently I'm away, so I was just asking if that change could cause some incompatibilities when compiling. The only error I had before was the missing std::stof function, because with sdk 10.5 c++11 is not supported...
|
If things don't start working, as a blunt fix, you could of course just implement std::stof for non-Windows platforms yourself. (Generally it's not recommended to change/add stuff in the std:: namespace but sometimes it's an appropriate quick fix.)
edit : At least with the Visual Studio C++ standard libary, std::stof is just a wrapper with some exception throwing when errors happen for the C library function strtof.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-31-2017, 02:18 PM
|
#13
|
Human being with feelings
Join Date: Dec 2015
Posts: 39
|
Quote:
Originally Posted by Xenakios
If things don't start working, as a blunt fix, you could of course just implement std::stof for non-Windows platforms yourself. (Generally it's not recommended to change/add stuff in the std:: namespace but sometimes it's an appropriate quick fix.)
edit : At least with the Visual Studio C++ standard libary, std::stof is just a wrapper with some exception throwing when errors happen for the C library function strtof.
|
Ok, thank you again, I'll try very soon !
...as stof, strtof too seems to be c++11 only...
|
|
|
01-31-2017, 04:52 PM
|
#14
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by br_ck1
strtof too seems to be c++11 only...
|
Should not be since it's not even a C++ function but just a C function.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:04 AM.
|