Include files and VPATH

Include files and VPATH

Аватар пользователя sfuniroma2

Hi there,
I am observing an inconvenient behaviour.

Scenario: a directory D1 contains some source and include files; another directory D2 contains different versions of the include files only.

D1/try.f:
program try

include 'defines.inc'


a(1) = 0.0
stop
end
D1/defines.inc:
integer isize
parameter (isize=1000)
double precision a(isize)

D2/defines.inc:
integer isize
parameter (isize=1000000)
double precision a(isize)

I now issue from D2 the following:
[sfilippo@gauss D2]$ ifc -I. -o try ../D1/try.f
program TRY

11 Lines Compiled
[sfilippo@gauss D2]$ size try
text data bss dec hex filename
117990 42816 18184 178990 2bb2e try

If I issue from D1:
[sfilippo@gauss D1]$ ifc -I . -o try try.f
program TRY

11 Lines Compiled
[sfilippo@gauss D1]$ size try
text data bss dec hex filename
117990 42816 18184 178990 2bb2e try


If I then remove D1/defines.inc and go again to D2 I get:

[sfilippo@gauss D2]$ ifc -I. -o try ../D1/try.f
program TRY

11 Lines Compiled
[sfilippo@gauss D2]$ size try
text data bss dec hex filename
117990 42816 8010184 8170990 7cadee try


My reading is: in the first case the include is taken from the same ../D1 directory as the source file, even if I specifically put -I . ahead of that.
This makes it impossible to build multiple versions of the same code by using the VPATH feature of make.

Am I doing anything wrong? I am on RedHat 7.3, kernel 2.4.18, glibc 2.2.5, IFC 7.0.

Thanks
Salvatore



2 posts / 0 новое
Последнее сообщение
Пожалуйста, обратитесь к странице Уведомление об оптимизации для более подробной информации относительно производительности и оптимизации в программных продуктах компании Intel.
Аватар пользователя Martyn Corden (Intel)

I think your reading is correct. The include file is always taken from the same directory as the source file if it is there. Neither -I nor -X (to remove standard directories from the search path) change this. I believe this matches the behavior of g77 with -I.

If you wish to request a change to this behavior, (e.g., for -X to remove also the local source directory from the search path), please submit an issue to https://premier.intel.com

As a workaround, you could choose to keep all the different versions of include files in separate directories, and none in the original source directory. An easy way to do this might be to create an include subdirectory for each source directory. Then your standard build would have something like -I./include, and it would be straightforward to modify this to pick up the include files from any other directory instead.

Martyn

Зарегистрируйтесь, чтобы оставить комментарий.