Cannot define a string having blanks as a macro value.

Cannot define a string having blanks as a macro value.

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

I need to generate a message whose content I wish to pass at compile time using the option  -Dname="string".

It seems impossible to pass a string having blanks, whatever combination of single and/or double quotes I use.

The documentation simply states ( http://software.intel.com/sites/products/documentation/doclib/stdxe/2013... ) :

...
-Dname=value :
...
value : Is an optional integer or an optional character string delimited by double quotes; for example, Dname=string.
...

without any advice about the string content.

Here is a simple example.

$ cat testfppi.f
      PRINT *,OPERATING_SYSTEM
      END

# NB : here the blanks between double and single quotes are for readability only, I did not use them actually.

$ ifort -V -fpp -E -DOPERATING_SYSTEM=" 'Red Hat Linux' "  testfppi.f                 
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 6, Version 13.0.0.079 Build 20120731
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.
ifort: error #10236: File not found:  'Hat'
ifort: error #10236: File not found:  'Linux'

# 1 "testfppi.f"
      PRINT *,Red
      END

I also tried escaping the blanks by backslashes, without success.
Is that the intended way of working for "-D" ? Is there any way to have blanks in such a string ?

Thanks in advance.

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

The problem you are experiencing may be with your shell

$ ifort -V -fpp -E "-DOPERATING_SYSTEM=""'Red Hat Linux""" testfppi.fur

You will need to look at your shell/make documentation as to how to pass quotes. In the above I used two " marks. Your shell may have an alternate way to pass quotes.

Jim Dempsey

www.quickthreadprogramming.com
Аватар пользователя e745200

Thanks Jim.
You are right: the shell has a role in this issue. I use intermediate scripts for accessing different versions of the compiler, and subsequent passages of quoted arguments mess them up.
The direct access to the executable, after having run fortvars.sh, gives the proper result once I used the following syntax (double quoting a single-quoted string):

ifort -V -fpp -DOPERATING_SYSTEM="'Red Hat Linux'" testfpp.f90

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