[macstl-dev] template with C linkage

Glen Low glen.low at pixelglow.com
Mon Feb 7 08:05:56 WST 2005

  • Previous message: [macstl-dev] template with C linkage
  • Next message: [macstl-dev] macstl 0.2.1 beats the autovectorizing Intel ICC 8.1
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]


On 06/02/2005, at 8:57 AM, Glen Low wrote:

> David:
>
> On 06/02/2005, at 2:28 AM, David Chilton wrote:
>
>> Glen,
>> After much tinkering, it seems the problem comes in with the  
>> -Wp,-header-mapfile,... option that is passed by Xcode.  I couldn't  
>> get benchmark.cpp to compile from the command line so i started  
>> putting in options from the Xcode build results window until it  
>> built.  Finally, and tried to compile the main.cpp given below.  It  
>> works with the std valarray straight away, but gives errors when i  
>> try to use macstl/valarry.  But It works when I add  
>> -Wp,-header-mapfile,[PATH_TO_BENCHMARK_BUILD]/benchmark.hmap to the  
>> gcc call, without that it gives loads of errors.  I can't seem to  
>> find any documentation on the hmap file or how to make one work, or  
>> why it deosn't work without it.
>>
>> Here's the command line that does build properly:
>> /usr/bin/gcc-3.3 /Users/chiltie/Desktop/main.cpp -o  
>> /Users/chiltie/Desktop/main -lstdc++ -DUSE_MACSTL  
>> -Wp,-header-mapfile,/Users/chiltie/Desktop/macstl/mac/build/ 
>> macstl.build/benchmark.build/benchmark.hmap
>>
>> here's the one that doesn't:
>> /usr/bin/gcc-3.3 /Users/chiltie/Desktop/main.cpp -o  
>> /Users/chiltie/Desktop/main -lstdc++ -DUSE_MACSTL
>
> It's rather perplexing. I use almost the same command line as yours:
>
> /usr/bin/gcc-3.3 main.cpp -lstdc++ -DUSE_MACSTL -I../macstl -o main.o
>
> where the -I is the path to the base of the outermost macstl  
> directory, and I get no errors.
>
> Googling for "template with C linkage" turns up about 700+ pages, some  
> detailing issues even with system headers on certain combinations of  
> operating systems and machines.
>

Finally figured it out. The bug only hits when you put macstl in  
/usr/include or symlink to it. Apparently gcc automatically encloses  
all such headers in an extern "C" block, see  
http://gcc.gnu.org/onlinedocs/cpp/System-Headers.html. The URL claims  
this is only in operation "on very old systems", so perhaps it's a bug  
on OS X.

I tried using the #pragma GCC system_header directive but it didn't  
seem to take, and in any case would be inaccurate in intent for macstl  
headers -- so I'll change the ReadMe.rtf to highlight this issue.

Thanks for your help!

Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com




  • Previous message: [macstl-dev] template with C linkage
  • Next message: [macstl-dev] macstl 0.2.1 beats the autovectorizing Intel ICC 8.1
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the macstl-dev mailing list