darylnak
darylnak

Reputation: 239

Argument unused during compilation?

From the research I have done, the problem seems to be with clang. If that is the case, how would I fix this on a Mac? Would switching to Ubuntu/Linux be a better option?

I'm not sure if it is relevant, but my professor is having us code using C syntax using g++ and saving our files as '.cpp' before we dive into C++.

Warning:

clang: warning: argument unused during compilation: '-ansi' [-Wunused-command-line-argument]

Makefile:

CC = g++

calendar: main.o calendar.o appt.o day.o time.o
    $(CC) main.o calendar.o appt.o day.o time.o -g -ansi -Wall -o calendar.out

%.o: %.cpp
    $(CC) -Wall -c $<

Upvotes: 1

Views: 9059

Answers (1)

Mike Kinghan
Mike Kinghan

Reputation: 61560

You are correct in believing that this warning is issued by clang++ in these circumstances and not by g++, and that you see it on your Mac because g++ is really clang++.

The GCC option -ansi is meaningful for compilation and not meaningful for linkage. Clang is warning you because you are passing it in your linkage recipe:

$(CC) main.o calendar.o appt.o day.o time.o -g -ansi -Wall -o calendar.out

where it is ineffective, and not passing it to your compilation recipe:

$(CC) -Wall -c $<

The wording of the diagnostic is misleading since it is provoked here precisely by the absence of compilation. Nevertheless, it does draw attention to a mistake on your part. Remove -ansi from your linkage recipe and add it to your compilation recipe.

Upvotes: 2

Related Questions