Error c2129: static function declared but not defined

Source: Internet
Author: User

This problem occurs today when a C function is exposed to LUA.

The approximate code is this,

Header file:

#ifndef level_designer_h#define Level_designer_hextern "C" {#include "lualib.h" #include "tolua_fix.h"}static int SaveFileDialog (lua_state *tolus_s); static int OpenFileDialog (lua_state *tolus_s); int Open_windows_lua (Lua_State * tolus_s); #endif

Source file:

#include "LevelDesignerUtils.h" #include <afxwin.h>//MFC core components and standard components # include <afxext.h>//MFC Extension # include <afxdisp.h>//MFC Automation class//wchar to Charvoid tc2c (const PTCHAR TC, char * c) {#if defined (UNICODE) Wid Echartomultibyte (CP_ACP, 0, TC,-1, C, wcslen (TC), 0, 0); C[wcslen (TC)] = 0; #elselstrcpy ((PTSTR) c, (PTSTR) TC); #endif} static int OpenFileDialog (Lua_state *tolus_s) {//TODO: Add Command handler code here CFileDialog *dlg = new CFileDialog (true, NULL, NULL, of n_hidereadonly | Ofn_overwriteprompt, _t ("JSON file (*.json) |*.json| configuration file (*.dat) |*.dat| All Files (*. *) |*.*| |")); Nt_ptr nresponse = Dlg->domodal (); CString Filpath = ""; if (IDCANCEL = = nresponse) {delete dlg;} else if (IDOK = = nresponse) {Filpath = Dlg->getpathname ();d elete Dlg;} Char Filepathc[max_path]; TC2C (Filpath.getbuffer (), filepathc); Lua_pushstring (tolus_s, FILEPATHC); return 1;} static int SaveFileDialog (Lua_state *tolus_s) {CFileDialog *dlg = new CFileDialog (false, NULL, NULL, OFN_HIDEREADONLY | Ofn_overwriteprompt,_t ("JSON file (*.json) |*.json| configuration file (*.dat) |*.dat| All Files (*. *) |*.*| |")); Nt_ptr nresponse = Dlg->domodal (); CString Filpath = ""; if (IDCANCEL = = nresponse) {delete dlg;} else if (IDOK = = nresponse) {Filpath = Dlg->getpathname ();d elete Dlg;} Char Filepathc[max_path]; TC2C (Filpath.getbuffer (), filepathc); Lua_pushstring (tolus_s, FILEPATHC); return 1;} int Open_windows_lua (lua_state *tolus_s) {lua_register (tolus_s, "Win_openfiledialog", OpenFileDialog); Lua_register ( tolus_s, "Win_savefiledialog", SaveFileDialog); return 0;}

 

Later flip through, find out why:

 A static function can only be seen in the file that declares it, cannot be called by other files, that is, a static function can only be called in a file that is known to it, and cannot be called in any other file.

Of course, it's completely unnecessary for me to declare the static function in the header file. After removal, it's ready.

Error c2129: static function declared but not defined

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.