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?
clear_screenis defined interm.hascur_term->type.Strings[5](at least on my system), hence the problem with->. Seeg++ -Eoutput to see what preprocessor does. So essentially you need to use a name different fromclear_screento avoid conflict.