Hi, all. It's my first time to ask some questions in this list.
The first question is whether there is a keybinding for commenting some region
of C/C++ codes in Xcode. I can do the same thing in GNU Emacs quickly by hit
the keystrokes M-;. I hope I can do it in Xcode. Any suggestion?
The second question is about the convention of the standard namespace in C++.
firstly, let's read the following classic example in C/C++:
,-----------------------------
| #include <cstdio>
| #include <cmath>
|
| double fabs(double a)
| {
| return -1.0*a;
| }
|
| int main()
| {
| double b=fabs(3.0);
| double c=std::fabs(3.0);
| printf("%f, %f\n",b,c);
| }
`-----------------------------
The Xcode (or Apple Clang) gives the results with both 3.000000. I have tried
to compile the same code by GCC on Fedora 22 and obtain the opposite results
with both -3.000000. It's ridiculous since abs and std::abs are lying in
different namespaces. I also compile the following C/C++ codes:
,-----------------------
| #include <cstdio>
| #include <cmath>
|
| int abs(int a)
| {
| return -1*a;
| }
|
| int main()
| {
| int b=abs(3);
| int c=std::abs(3);
| printf("%b, %c\n", b, c);
| }
`-----------------------
in Xcode. Now, it gives me the error about ambiguous calling to abs function
while GCC gives me the right answer. After browsing the hierarchy of C/C++
headers
,------------------------------------------------------------------------------------------------------------------
| $ cd /Applications/Xcode.app/Contents
| $ find . -iname 'cmath'
|
./Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/cmath
|
./Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/cmath
|
./Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/cmath
|
./Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/cmath
|
./Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/cmath
|
./Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/tr1/cmath
| ./Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath
`------------------------------------------------------------------------------------------------------------------
I found out that Apple Clang doesn't offer the newest math library. Anyone
knows what happened between math library and standard namespace?
Best wishes,
Jun-Qi Hu
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com This email sent to [email protected]
