最近我在我的Windows 7机器上安装了node.js.
在执行JavaScript时,我得到一个未定义的消息以及表达式的成功执行.
这有什么不对?我没有注意到任何其他副作用.
我从GCC 4.8.1得到一个非常奇怪的错误,内联函数.
我在头文件(debug.h
和error.h
)中定义了两个几乎相同的内联函数src/include/
,唯一的区别是它们打印的内容 - DEBUG:
消息的一个前缀,另一个%s: error: %s
(程序名,错误消息).在定义内联函数和编译调试版本时(因此它设置宏DEBUG=1
),我得到了许多未定义的引用错误:
src/main_debug.o
gcc -osrc/main_debug.o src/main.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g -DCC="\"gcc\"" -DCFLAGS="\"-Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g\"" -DDEBUG=1 -DBTCWATCH_VERSION="\"0.0.1\""
src/lib/btcapi_debug.o
gcc -osrc/lib/btcapi_debug.o src/lib/btcapi.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g -DCC="\"gcc\"" -DCFLAGS="\"-Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g\"" -DDEBUG=1
src/lib/libbtcapi_debug.a
ar rc src/lib/libbtcapi_debug.a src/lib/btcapi_debug.o
ranlib src/lib/libbtcapi_debug.a
src/lib/cmdlineutils_debug.o
gcc -o src/lib/cmdlineutils_debug.o src/lib/cmdlineutils.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og …
Run Code Online (Sandbox Code Playgroud) 我想在多参数函数上传递'undefined'的值但不省略参数.
"没有省略参数"是什么意思.我的意思是我们不应该只省略parm2
这个例子:
function myFunction (parm1, parm2) {}
myFunction("abc");
Run Code Online (Sandbox Code Playgroud)
这确实会做出parm2
未定义的,但是我不允许这样做,因为我需要在省略的参数之后指定其他参数,所以前面的方法在我想做parm1
未定义的情况下也行不通但是也想要此后的其他参数保持一个值.
我试过用以下方法解决问题:
myFunction( ,"abc"); //doesn't seem to work
Run Code Online (Sandbox Code Playgroud)
更新:
并且 «这现在可靠地起作用了.myFunction(undefined, "abc");
但是,值得一提的是:
设置变量
undefined
被认为是一种不好的做法,我们应该使用null
.
我只是有一个小问题.
为什么undefined == undefined
返回true
,但是undefined >= undefined
是false
?
undefined
等于undefined
.
但它不等于或更大?
我在PHP中收到以下错误
注意未定义的偏移1:在C:\ wamp\www\includes\imdbgrabber.php第36行
以下是导致它的PHP代码:
<?php
# ...
function get_match($regex, $content)
{
preg_match($regex,$content,$matches);
return $matches[1]; // ERROR HAPPENS HERE
}
Run Code Online (Sandbox Code Playgroud)
错误是什么意思?
当我尝试在不同的PHP服务器上运行我的脚本时,出现了一个新问题.
在我的旧服务器上,以下代码似乎工作正常 - 即使没有s
声明参数.
<?php
if ($_GET['s'] == 'jwshxnsyllabus')
echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/jwshxnporsyllabus.xml', '../bibliographies/jwshxnbibliography_')\">";
if ($_GET['s'] == 'aquinas')
echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/AquinasSyllabus.xml')\">";
if ($_GET['s'] == 'POP2')
echo "<body onload=\"loadSyllabi('POP2')\">";
elseif ($_GET['s'] == null)
echo "<body>"
?>
Run Code Online (Sandbox Code Playgroud)
但现在,在我本地计算机上的本地服务器(XAMPP - Apache)上,当没有s
定义值时,我收到以下错误.
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 43
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 45
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 47
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 49
Run Code Online (Sandbox Code Playgroud)
如果声明了一个值 …
所以我想开始一项任务,我的教授给我们一个Main.cpp,Main.h,Scanner.cpp,Scanner.h和其他一些实用工具.
我的工作是创建一个Similarity类来使用余弦和Jaccard系数比较文档.但是,我似乎无法正确链接项目,因此我无法启动实际代码.
经过几个小时的努力,看看我做错了什么,我需要新鲜的眼睛看看我做错了什么,我怀疑这是显而易见的.
这是Main.cpp
#include "Main.h"
using namespace std;
static const string TAG = "Main: ";
int main(int argc, char *argv[])
{
string inStreamName;
string logStreamName;
string outStreamName;
ofstream outStream;
string timeCallOutput;
Scanner inStream;
Similarity similarity;
///////////////////////////////////////////////////////////////
// Boilerplate for naming files and opening files
Utils::CheckArgs(3, argc, argv, "infilename outfilename logfilename");
outStreamName = static_cast<string>(argv[2]);
logStreamName = static_cast<string>(argv[3]);
Utils::FileOpen(outStream, outStreamName);
Utils::LogFileOpen(logStreamName);
timeCallOutput = Utils::timecall("beginning");
Utils::logStream << timeCallOutput << endl;
Utils::logStream << TAG << "Beginning execution" << endl;
Utils::logStream << TAG << …
Run Code Online (Sandbox Code Playgroud) 除了创建一个功能,有检查的值是一个较短的方式undefined
,null
或者false
只在JavaScript?
下面的if语句相当于if(val===null && val===undefined val===false)
代码工作正常,我正在寻找更短的等价物.
if(val==null || val===false){
;
}
Run Code Online (Sandbox Code Playgroud)
val==null
当val=undefined
或时,以上评估为真val=null
.
我在考虑使用按位运算符或其他一些技巧.
说我有以下代码:
function One() {}
One.prototype.x = undefined;
function Two() {}
var o = new One();
var t = new Two();
Run Code Online (Sandbox Code Playgroud)
o.x
并且t.x
都会评估undefined
.o.hasOwnProperty('x')
并且t.hasOwnProperty('x')
都会返回虚假; 同样的道理propertyIsEnumerable
.两个问题:
undefined
?一个小警告:在o中执行(对于propName)循环将产生'x'作为字符串之一,而在t中执行则不会 - 因此它们在内部表示的方式存在差异(至少在Chrome中).
我正在尝试使用C++教科书中的示例中的相邻列表来编写图形类,当我使用此命令编译时:代码:g ++ -o prog program.cpp ...我收到以下错误:
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
......这意味着什么?它可能会成为我的代码的一个问题,但我觉得它可能比这更深,因为我已经为几个不同的项目得到了同样看似莫名其妙的错误,其中许多项目以不同方式解决,不幸的是完全意外地.
我在某处读到它可能与我是使用32位还是64位库有关,并且可能需要使用标签-m32或-m64,但我不确定这是否适用于此.有趣的是,当我尝试添加-m64标记时,我得到了相同的确切错误,但是当我尝试使用-m32标记时,我得到了相同的错误,除了它说
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
代替.
主要是我只想知道错误所说的世界是什么.我习惯于调试在代码中给出特定行等的编译时错误,但我无法从中识别出类似的内容.有任何想法吗?
如果它有所帮助,我将使用2008年末的Macbook和Intel Core 2 Duo(64位),而我正在运行OS X Lion(10.7.2),我认为这是最新版本.另外,我使用的是gcc 4.2.1版.
undefined ×10
javascript ×5
compilation ×2
function ×2
php ×2
symbols ×2
c ×1
c++ ×1
console ×1
g++ ×1
header-files ×1
hyperlink ×1
inline ×1
node.js ×1
null ×1
object ×1
offset ×1
properties ×1