Reputation: 135
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
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