1 |
2016-06-21 12:54 GMT+08:00 Lei Zhang <zhanglei.april@×××××.com>: |
2 |
> 2016-06-17 20:44 GMT+08:00 Lei Zhang <zhanglei.april@×××××.com>: |
3 |
>> After putting about eight "#define _GNU_SOURCE"s in various *.cpp |
4 |
>> files, it seems to work now :) |
5 |
> |
6 |
> I was wrong; it doesn't work... I still can't figure out a good solution :( |
7 |
> |
8 |
> Take glibc's strtoll_l for example: it's hidden by _GNU_SOURCE in |
9 |
> stdlib.h and used exclusively by libc++'s header <locale>; but |
10 |
> defining _GNU_SOURCE in <locale> could be too late, since stdlib.h |
11 |
> might be included prior to <locale>. |
12 |
> |
13 |
> Though glibc's stdlib.h is only explicitly included in <cstdlib>, |
14 |
> defining _GNU_SOURCE in <cstdlib> doesn't work either. It turns out |
15 |
> strtoll_l (and others) is not directly protected by _GNU_SOURCE, but |
16 |
> by __USE_GNU, which is in turn defined in features.h according to |
17 |
> _GNU_SOURCE. That means "#define _GNU_SOURCE" must appear before the |
18 |
> inclusion of features.h, and it's not very clear where "#undef |
19 |
> _GNU_SOURCE" should be put. |
20 |
> |
21 |
> Any suggestions? |
22 |
|
23 |
So far the only feasible solution I can think of is to wrap every |
24 |
inclusion of C headers in libc++ with a pair of "#define _GNU_SOURCE" |
25 |
and "#undef _GNU_SOURCE", thus making sure _GNU_SOURCE is defined |
26 |
before any implicitly inclusion of features.h. It is cumbersome, but |
27 |
works. I haven't really figured out if this solution is 100% |
28 |
error-proof. |
29 |
|
30 |
P.S.: sorry for my previous mis-sent message. |
31 |
|
32 |
|
33 |
Lei |