Hello
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
In my test scetch i define my own print function
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!
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
Code:
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 "
LUA_QL("print"));
if (i>1) lua_compat_print("\t");
lua_compat_print(s);
lua_pop(L, 1); /* pop result */
}
lua_compat_print("\n");
return 0;
}
In my test scetch i define my own print function
Code:
extern "C" {
void lua_compat_print(const char *s) {
Serial.print(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!