2

I have the following code:

gcc test.c -o test -D ARGUMENT 2

and I want it to define ARGUMENT with a value of 2 but it says cannot find file 2 or something. How do I do this?

1
  • 2
    One note (wording difference might made it difficult for you) - what you are doing are not "creating command line arguments" - those your program will get at runtime via argc/argv pair of arguments to main(), but you are defining the preprocessor macro with the name "ARGUMENT" to expand to "2". Take a look at the "An introduction to GCC" - amazon.com/Introduction-GCC-Brian-J-Gough/dp/0954161793/… I personally do not have it, but from the glance at the content it seems nice. Commented Oct 27, 2009 at 21:07

3 Answers 3

12

Try

-DARGUMENT=2

Sign up to request clarification or add additional context in comments.

1 Comment

@bob: it happens even to the best.
0

gcc test.c -o test -D ARGUMENT=2

Comments

0

You can also use gcc test.c -o test -DARGUMENT.

ARGUMENT will be defined with no value but it is still possible to check it using #ifdef and friends.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.