error: 'CFLAGS' does not name a type

278 views Asked by At

This is my makefile:

CFLAGS=-Wall -g -O2

clean:
    rm -f ex1

And when I run a script, for example, this one (ex3.c):

#include <stdio.h>

int main()
{
    int age = 10;
    int height = 72;

    printf("I am %d years old.\n", age);
    printf("I am %d inches tall.\n", height);

    return 0;
}

I get the following error:

$ g++ Makefile.c -o makefile
Makefile.c:1:1: error: 'CFLAGS' does not name a type
CFLAGS=-Wall -g
^g++     ex3.c   -o ex3
$
1

There are 1 answers

0
Thomas Matthews On

Please don't compile the makefile.

Use the make utility instead.

Synonyms include nmake and gmake.

The makefile should be passed to the make program or build utility.