undefined

Embedding Lua in C++

会有一股神秘感。 提交于 2019-12-17 22:36:32
问题 I've been trying to embed lua in a c++ application but to no avail since the compiler complains about "lua_open".I'm using Lua 5.2. I found alot of articles claiming that lua_open() was replaced in the fifth version but none of them mentioned with what. Here's the code I am trying to compile extern "C" { #include "../lua/lua.h" #include "../lua/lualib.h" #include "../lua/lauxlib.h" } int main() { int s=0; lua_State *L = lua_open(); // load the libs luaL_openlibs(L); luaL_dofile(L,"example.lua

Linker Error C++ “undefined reference ” [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 18:16:09
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I fix it? Trying to compile my program via g++ -o prog1 main.cpp -std=c++0x I get the error: /tmp/cc1pZ8OM.o: In function `main': main.cpp:(.text+0x148): undefined reference to `Hash::insert(int, char)' collect2: error: ld returned 1 exit status main.cpp #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include

Qt5.1/Qt5.2 + Mac OS 10.9 (Mavericks) + XCode 5.0.2, Undefined symbols for architecture x86_64

北战南征 提交于 2019-12-17 15:45:08
问题 Environment : Mac OS 10.9 + Qt5.1/Qt5.2 + OpenCV2.4.7 + XCode(5.0.2) I can compile the following program via terminal g++ -L/usr/local/lib -lopencv_core -lopencv_highgui \ -I/usr/local/include main.cpp The program a.out runs normally. However, when using Qt 5.1/5.2 to run this OpenCV program, I got "Undefined symbols for architecture x86_64". However, Qt5 works normally for a simple HelloWorld c++ program. What is going on ? Here is the code. #include <iostream> #include "opencv2/highgui

Check if object exists in JavaScript

坚强是说给别人听的谎言 提交于 2019-12-17 14:59:11
问题 How do I verify the existence of an object in JavaScript? The following works: if (!null) alert("GOT HERE"); But this throws an Error: if (!maybeObject) alert("GOT HERE"); The Error: maybeObject is not defined. 回答1: You can safely use the typeof operator on undefined variables. If it has been assigned any value, including null, typeof will return something other than undefined. typeof always returns a string. Therefore if (typeof maybeObject != "undefined") { alert("GOT THERE"); } 回答2: There

Why is my JavaScript hoisted local variable returning undefined but the hoisted global variable is returning blank? [duplicate]

梦想的初衷 提交于 2019-12-17 14:44:28
问题 This question already has answers here : Why do I get the value “result” for this closure? (3 answers) Closed 4 years ago . As part of my learning JavaScript, I try to write code to demonstrate the concept I am learning; today I'm learning hoisted variables. Here is the code I wrote: console.log("A: My name is " + name); function happy() { console.log ("1: I am " + feeling); var feeling = "happy"; console.log ("2: I am " + feeling); } happy(); var name = "Jim"; console.log("B: My name is " +

Count of “Defined” Array Elements

依然范特西╮ 提交于 2019-12-17 10:52:33
问题 Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like to get the count of elements which are defined (i.e.: those which are not undefined ). Other than looping through the array, is there a good way to do this? 回答1: In recent browser, you can use filter var size = arr.filter(function(value) { return value !== undefined }).length; console.log(size); Another method, if the browser supports indexOf for arrays: var size = arr.slice(0).sort().indexOf

Javascript - removing undefined fields from an object [duplicate]

左心房为你撑大大i 提交于 2019-12-17 10:32:47
问题 This question already has answers here : Remove blank attributes from an Object in Javascript (31 answers) Closed 2 years ago . Is there a clean way to remove undefined fields from an object? i.e. > var obj = { a: 1, b: undefined, c: 3 } > removeUndefined(obj) { a: 1, c: 3 } I came across two solutions: _.each(query, function removeUndefined(value, key) { if (_.isUndefined(value)) { delete query[key]; } }); or: _.omit(obj, _.filter(_.keys(obj), function(key) { return _.isUndefined(obj[key]) }

PHP Undefined index error $_FILES?

给你一囗甜甜゛ 提交于 2019-12-17 09:58:42
问题 I am new to PHP and am following a tutorial on YouTube. I have everything working in this file, except for the file uploading, any help would be appreciated. Here is the error i am getting: *NOTE: I have looked for this many times, but could not find undefined index error relevant to $_FILES... Notice: Undefined index: avatar in /Applications/xxx on line 95 Notice: Undefined index: avatar in /Applications/xxx on line 96 Notice: Undefined index: avatar in /Applications/xxx on line 97 Notice:

What reason is there to use null instead of undefined in JavaScript?

旧城冷巷雨未停 提交于 2019-12-17 08:17:14
问题 I've been writing JavaScript for quite a long time now, and I have never had a reason to use null . It seems that undefined is always preferable and serves the same purpose programmatically. What are some practical reasons to use null instead of undefined ? 回答1: Null and undefined are essentially two different values that mean the same thing. The only difference is in the conventions of how you use them in your system. As some have mentioned, some people use null for meaning "no object" where

Returning const reference to local variable from a function

时光总嘲笑我的痴心妄想 提交于 2019-12-17 07:05:33
问题 I have some questions on returning a reference to a local variable from a function: class A { public: A(int xx) : x(xx) { printf("A::A()\n"); } }; const A& getA1() { A a(5); return a; } A& getA2() { A a(5); return a; } A getA3() { A a(5); return a; } int main() { const A& newA1 = getA1(); //1 A& newA2 = getA2(); //2 A& newA3 = getA3(); //3 } My questions are => Is the implementation of getA1() correct? I feel it is incorrect as it is returning the address of a local variable or temporary.