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 834531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:41:10+00:00 2026-05-15T04:41:10+00:00

I have a Makefile for a C program that has the declaration CC?=gcc Changing

  • 0

I have a Makefile for a C program that has the declaration

CC?=gcc

Changing it to

CC?=g++

does NOT make it compile with g++. Changing it to

CC=g++

DOES make it use g++.

So I wonder what the ?= operator does? My guess is that it looks at a environment variable to decide which compiler to use and if it’s not set then use gcc? Anyone who can clear this up?

  • 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-15T04:41:10+00:00Added an answer on May 15, 2026 at 4:41 am

    From http://www.gnu.org/software/make/manual/make.html:

    There is another assignment operator
    for variables, `?=’. This is called a
    conditional variable assignment
    operator, because it only has an
    effect if the variable is not yet
    defined. This statement:

     FOO ?= bar
    

    is exactly equivalent to this (see The
    origin Function):

     ifeq ($(origin FOO), undefined)
       FOO = bar
     endif
    

    Probably CC is already defined as gcc, so CC ?= g++ won’t override the existing gcc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following makefile that I use to build a program (a kernel,
I have a Makefile so that when I type make the following commands run:
I have a C++ program that will run on several machines that use a
I have a make file that contains this code: all: main.o Etudiant.o gcc -lobjc
I have written a small makefile for a few simple C programs that compiles
I have a makefile project that builds and links a DLL, using the command-line
I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
I have a Makefile that looks something like this: sometarget: command_one # calls fork()
Let's say I have a makefile with the rule %.o: %.c gcc -Wall -Iinclude
i have made a program in C using the gcc compiler. Right now it

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.