1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
commit 6b95b832d72696df0278ac7b9d290c96b798ef07
Author: Milian Wolff <mail@milianw.de>
Date: Tue Apr 17 11:14:02 2012 +0200
Fix gcc include-path and macro computation on machines with old GCC.
Whe default to calling GCC with -std=c++0x and fallback to a call
without that argument when the former fails.
BUG: 298252
diff --git a/languages/cpp/setuphelpers.cpp b/languages/cpp/setuphelpers.cpp
index d3ced10..59bb850 100644
--- languages/cpp/setuphelpers.cpp
+++ languages/cpp/setuphelpers.cpp
@@ -31,12 +31,13 @@
using namespace KDevelop;
namespace CppTools {
-QStringList gccSetupStandardIncludePaths();
-const QVector<rpp::pp_macro*>& gccStandardMacros();
#ifdef _MSC_VER
QStringList msvcSetupStandardIncludePaths();
const QVector<rpp::pp_macro*>& msvcStandardMacros();
+#else
+QStringList gccSetupStandardIncludePaths();
+const QVector<rpp::pp_macro*>& gccStandardMacros();
#endif
QStringList setupStandardIncludePaths()
diff --git a/languages/cpp/setuphelpers_gcc.cpp b/languages/cpp/setuphelpers_gcc.cpp
index 5b8fdda..83c6052 100644
--- languages/cpp/setuphelpers_gcc.cpp
+++ languages/cpp/setuphelpers_gcc.cpp
@@ -40,7 +40,7 @@ using namespace KDevelop;
namespace CppTools {
-QStringList gccSetupStandardIncludePaths()
+QStringList gccSetupStandardIncludePaths(bool withStdCpp0x)
{
QStringList includePaths;
@@ -59,7 +59,12 @@ QStringList gccSetupStandardIncludePaths()
// /usr/lib/gcc/i486-linux-gnu/4.1.2/include
// /usr/include
// End of search list.
- proc <<"gcc" << "-std=c++0x" <<"-xc++" <<"-E" <<"-v" <<NULL_DEVICE;
+ proc << "gcc";
+ if (withStdCpp0x) {
+ // see also: https://bugs.kde.org/show_bug.cgi?id=298252
+ proc << "-std=c++0x";
+ }
+ proc << "-xc++" << "-E" << "-v" << NULL_DEVICE;
// We'll use the following constants to know what we're currently parsing.
const short parsingInitial = 0;
@@ -100,6 +105,9 @@ QStringList gccSetupStandardIncludePaths()
}
}
}
+ } else if (withStdCpp0x) {
+ // fallback to include-path computation without -std=c++0x arg for old gcc versions
+ return gccSetupStandardIncludePaths(false);
} else {
kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
}
@@ -107,7 +115,12 @@ QStringList gccSetupStandardIncludePaths()
return includePaths;
}
-QVector<rpp::pp_macro*> computeGccStandardMacros()
+QStringList gccSetupStandardIncludePaths()
+{
+ return gccSetupStandardIncludePaths(true);
+}
+
+QVector<rpp::pp_macro*> computeGccStandardMacros(bool withStdCpp0x = true)
{
QVector<rpp::pp_macro*> ret;
//Get standard macros from gcc
@@ -117,7 +130,12 @@ QVector<rpp::pp_macro*> computeGccStandardMacros()
// The output of the following gcc commands is several line in the format:
// "#define MACRO [definition]", where definition may or may not be present.
// Parsing each line sequentially, we can easily build the macro set.
- proc <<"gcc" << "-std=c++0x" <<"-xc++" <<"-E" <<"-dM" <<NULL_DEVICE;
+ proc << "gcc";
+ if (withStdCpp0x) {
+ // see also: https://bugs.kde.org/show_bug.cgi?id=298252
+ proc << "-std=c++0x";
+ }
+ proc << "-xc++" << "-E" << "-dM" <<NULL_DEVICE;
if (proc.execute(5000) == 0) {
QString line;
@@ -141,6 +159,9 @@ QVector<rpp::pp_macro*> computeGccStandardMacros()
}
}
}
+ } else if (withStdCpp0x) {
+ // fallback to macro computation without -std=c++0x arg for old gcc versions
+ return computeGccStandardMacros(false);
} else {
kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
}
|