Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:06:55+00:00 2026-05-14T15:06:55+00:00

I understand that CFLAGS (or CXXFLAGS for C++) are for the compiler, whereas CPPFLAGS

  • 0

I understand that CFLAGS (or CXXFLAGS for C++) are for the compiler, whereas CPPFLAGS is used by the preprocessor.

But I still don’t understand the difference.

I need to specify an include path for a header file that is included with #include — because #include is a preprocessor directive, is the preprocessor (CPPFLAGS) the only thing I care about?

Under what circumstances do I need to give the compiler an extra include path?

In general, if the preprocessor finds and includes needed header files, why does it ever need to be told about extra include directories? What use is CFLAGS at all?

(In my case, I actually found that BOTH of these allow me to compile my program, which adds to the confusion… I can use CFLAGS OR CPPFLAGS to accomplish my goal (in autoconf context at least). What gives?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:06:55+00:00Added an answer on May 14, 2026 at 3:06 pm

    The implicit make rule for compiling a C program is

    %.o:%.c
        $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
    

    where the $() syntax expands the variables. As both CPPFLAGS and CFLAGS are used in the compiler call, which you use to define include paths is a matter of personal taste. For instance if foo.c is a file in the current directory

    make foo.o CPPFLAGS="-I/usr/include"
    make foo.o CFLAGS="-I/usr/include"
    

    will both call your compiler in exactly the same way, namely

    gcc -I/usr/include -c -o foo.o foo.c
    

    The difference between the two comes into play when you have multiple languages which need the same include path, for instance if you have bar.cpp then try

    make bar.o CPPFLAGS="-I/usr/include"
    make bar.o CFLAGS="-I/usr/include"
    

    then the compilations will be

    g++ -I/usr/include -c -o bar.o bar.cpp
    g++ -c -o bar.o bar.cpp
    

    as the C++ implicit rule also uses the CPPFLAGS variable.

    This difference gives you a good guide for which to use – if you want the flag to be used for all languages put it in CPPFLAGS, if it’s for a specific language put it in CFLAGS, CXXFLAGS etc. Examples of the latter type include standard compliance or warning flags – you wouldn’t want to pass -std=c99 to your C++ compiler!

    You might then end up with something like this in your makefile

    CPPFLAGS=-I/usr/include
    CFLAGS=-std=c99
    CXXFLAGS=-Weffc++
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that UIAccelerometerDelegate is now deprecated as of ios5. I still need to
I understand that setup.py uses the same CFLAGS that were used to build Python.
I understand that this question may be subjective, this is why I need an
I understand that the CLR needs to do marshaling in some cases, but let's
I understand that the mapkit is used to show a device location in the
I understand that this a very noob problem, but when I try to create
I understand that this may not necessarily apply to just @properties, but they would
Understand that 1x1 widget size should be 72 dip x 72 dip, but this
I understand that @synthesize window; combined with @property 'auto-creates' your setters and getters, but
I understand that Internet Explorer is poor at supporting CSS3 - but is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.