conflicting declaration with 'C' linkage


Active member

I want to use lua language for teensy to use scripts from sd card. So i use lua libraries.
To use "print" function from lua to Serial in lua libraries used this one
void lua_compat_printf(char *fmt, ... );
void lua_compat_print(const char *s);

** If your system does not support `stdout', you can just remove this function.
** If you need, you can define your own `print' function, following this
** model but changing `fputs' to put the strings at a proper place
** (a console window or a log file, for instance).
static int luaB_print (lua_State *L) {
  int n = lua_gettop(L);  /* number of arguments */
  int i;
  lua_getglobal(L, "tostring");
  for (i=1; i<=n; i++) {
    const char *s;
    lua_pushvalue(L, -1);  /* function to be called */
    lua_pushvalue(L, i);   /* value to print */
    lua_call(L, 1, 1);
    s = lua_tostring(L, -1);  /* get result */
    if (s == NULL)
      return luaL_error(L, LUA_QL("tostring") " must return a string to "
    if (i>1) lua_compat_print("\t");
    lua_pop(L, 1);  /* pop result */
  return 0;

In my test scetch i define my own print function

extern "C" {
  void lua_compat_print(const char *s) {

So, in test scetch it work fine, but in big project i got error

D:\485\DIN Proshivki\Master_v2.11\Master_v2.11.ino: In function 'void lua_compat_print(const char*)':
D:\485\DIN Proshivki\Master_v2.11\Master_v2.11.ino:1192:38: error: conflicting declaration of 'void lua_compat_print(const char*)' with 'C' linkage
D:\485\DIN Proshivki\Master_v2.11\Master_v2.11.ino:1192:6: note: previous declaration with 'C++' linkage

In my scetch i have only one declaration of lua_compat_print, i dont understand, why i got this error, and what i need to do, to fix it.
Thanks for answers!
Maybe try it like this:

extern "C" void lua_compat_print(const char *s);
void lua_compat_print(const char *s) {

If that doesn't work, maybe when show us a screenshot of exactly what's at line 1192 where the compiler is complaining. Maybe there's some subtle detail?