lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Roberto,
 Sometimes gcc/g++ ignores how you call the compiler and uses the
extension of the file being compiled to decide if is C++ or C. Have
you tried to rename lpeg.c to lpeg.cpp ?

$ cat test.c
const char *func()
{
       return 0,0;
}

$ gcc -c test.c
test.c: In function 'func':
test.c:3: warning: return makes pointer from integer without a cast

$ gcc -c test.cpp
test.cpp: In function 'const char* func()':
test.cpp:3: error: invalid conversion from 'int' to 'const char*'

What is a warning in C is an error in C++

Cheers,
  Jose L.

2007/4/4, Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
When I compile lpeg (version 0.5) with g++ (that is, as C++ code), I get
the following error:

lpeg.c:395: error: invalid conversion from 'int' to 'const char*'

That line is as follows:

          return luaL_error(L, "too many pending calls/choices"), NULL;

(The function actually returns 'const char *'). If I remove the
LuaL_error call from the expression, the error disapears. (So, it seems
that NULL is still compatible with const char* ;) Parentheses around the
comma expression have no effect. Is this a bug in gcc? Or am I doing
something stupid?

I am using gcc version 4.0.3.

-- Roberto



--
 Jose L. Hidalgo Valiño (PpluX)
 ---- http://www.pplux.com ----