简体   繁体   English

OS X 10.8.5上的C ++ math.h

[英]C++ math.h on OS X 10.8.5

I have a C++ program that will not compile under OS X 10.8.5 with the g++ compiler. 我有一个C ++程序,无法在OS X 10.8.5下使用g ++编译器进行编译。 The problem seems to be with the math.h header file. 问题似乎出在math.h头文件上。

This is the version of g++ is 这是g ++的版本

g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/Users/densmore3/local/usr/local/bin/../libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
 Target: x86_64-apple-darwin14.0.0
 Configured with: ../gcc-4.9-20141029/configure --enable-   languages=c++,fortran
 Thread model: posix
 gcc version 4.9.2 20141029 (prerelease) (GCC) 

There are 40-50 errors of the type below. 以下是40-50类型的错误。 The code compiled fine on 10.6. 该代码在10.6上编译良好。 What is going on? 到底是怎么回事?

/Users/xxxx/local/usr/local/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include-fixed/math.h:203:1: error: ‘__header_always_inline’ does not name a type
__header_always_inline int __inline_isfinitef(float);

Users/densmore3/local/usr/local/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include-fixed/math.h:580:27: error: expected initializer before ‘__AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_9’
extern float __inff(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA);

Here is a piece of test code that gives the same error as my real code. 这是一段测试代码,它给出的错误与我的真实代码相同。 The error goes away if I remove the math.h include statement. 如果删除math.h include语句,错误将消失。

#include <iostream>
#include <math.h>
#include <stdio.h>
//#include <complex>
//#include <vector>

int main(int argc, const char * argv[])
{

    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}

The compile command I am using is: 我正在使用的编译命令是:

g++ test.cpp

gcc-4.8是在OS X 10.8上使用的正确版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM