Kunal
Kunal

Reputation: 135

passing string value in GCC comand using variable

I need to pass String Value in GCC command using variable

something like below

gcc -Dname= '"abc"'

but this "abc" will come in soime variable like

Name1=abc

Kindly tell will this work

gcc -Dname= $Name1

Upvotes: 0

Views: 1290

Answers (1)

user3920237
user3920237

Reputation:

If you're using Bash, variable substitution will work here.

$ Name1=abc
$ cat main.cpp
NAME
$ gcc -DNAME=\"$Name1\" -E main.cpp
"abc"

If you are using a different shell, i.e. zsh or fish, they should also contain info and man pages that tell you how variable substitution works for them.

Upvotes: 1

Related Questions