views:

46

answers:

2

I've tried using the /Fc flag which works with visual studio but get a message that it isn't recognized by the intel compiler.

I'm trying to write a test which uses data from a directory relative to the cpp test file, however the executable will be deployed elsewhere so it's hard to get it relative to the exe... hence i'd like an absolute path at compile time! How else could I get a path relative to the current cpp file?

Cheers, Jamie

A: 

Did you try out __BASE_FILE__?

It is documented in http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/cpp/lin/main_cls_lin.pdf on page 170. It is not ANSI standard but gcc also supports it. With some dirty #ifdef tricks you can manage to make it work for all compilers.

I have no Intel Compiler to check it, unfortunately.

jdehaan
Thanks for the great digging into poorly documented features. Unfortunately this returns the same thing as __FILE__ which is a relative file path.
Jamie Cook
A: 

This is apparently a bug in the Intel Compiler, it silently accepts and then ignores the /FC flag which should trigger absolute paths. The best work around I can find came from this thread that I started over at Intel forums:

To get _FILE_ to generate an absolute path it has to be in a header file which has been included via the "Additional Include Directories" which must be an absolute path.

For example create a file test.h which is in a directory "test_include" which isn't directly accessible from your include path, then when including the file use:

#include "test.h"

and make sure that the directory is specified in your Additional Include Directory section as an absolute path, you might have to do some fiddling with the macros... my include line looks like this:

"$(InputDir)..\include\test_include"
Jamie Cook