Reputation: 705
I got strange error from g++. The procedure for which the error prompts compiles itself excellent within other project, but here somehow not. Here is what g++ complains about:
g++ -c -Wall -pedantic clear_screen.cpp -lcurses -o .clear.o
clear_screen.cpp:6:6: error: expected initializer before ‘->’ token
make: *** [.clear.o] Error 1
The corresponding makefile part looks like:
CC=g++
CFLAGS=-c -Wall -pedantic
COMP=$(CC) $(CFLAGS)
.clear.o : clear_screen.cpp
$(COMP) clear_screen.cpp -lcurses -o $@
And the file in question consists of the following lines:
#include <unistd.h>
#include <term.h>
void clear_screen() {
if ( !cur_term ) { // line 6 is here
int result;
setupterm( NULL, STDOUT_FILENO, &result );
if (result <= 0) return;
}
putp( tigetstr( "clear" ) );
}
Where am I wrong?
Upvotes: 1
Views: 1466
Reputation: 3066
clear_screen
is defined in term.h
as cur_term->type.Strings[5]
(at least on my system), hence the problem with ->
. See g++ -E
output to see what preprocessor does. So essentially you need to use a name different from clear_screen
to avoid conflict.
Upvotes: 1