-
-
[旧帖] [求助]这段代码为什么在用mingw develop studio 和code blocks里面编译不过 0.00雪花
-
发表于: 2009-9-26 21:02 1275
-
#include <stdio.h>
extern inline int strcmp(const char *cs,const char *ct)
{
int d0,d1;
register int __res;
asm volatile(
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"3:"
:"=a" (__res),"=&s" (d0),"=&d" (d1)
:"1" (cs),"2"(ct)
);
return __res;
}
int main(void)
{
int a=strcmp("c","a");
printf("%d",a);
return 0;
}
各位帮我看看 这段代码为什么用gcc -o new.exe new.c 就可以通过?
为什么在用mingw develop studio 和code blocks里面编译不过?
提示:
--------------------Configuration: Test - Debug--------------------
Compiling source file(s)...
Main.cpp
Main.cpp: In function `int strcmp(const char*, const char*)':
Main.cpp:7: warning: asm operand 3 probably doesn't match constraints
Main.cpp:7: error: impossible constraint in `asm'
Main.cpp:6: warning: `int __res' might be used uninitialized in this function
Test.exe - 1 error(s), 2 warning(s)
extern inline int strcmp(const char *cs,const char *ct)
{
int d0,d1;
register int __res;
asm volatile(
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"3:"
:"=a" (__res),"=&s" (d0),"=&d" (d1)
:"1" (cs),"2"(ct)
);
return __res;
}
int main(void)
{
int a=strcmp("c","a");
printf("%d",a);
return 0;
}
各位帮我看看 这段代码为什么用gcc -o new.exe new.c 就可以通过?
为什么在用mingw develop studio 和code blocks里面编译不过?
提示:
--------------------Configuration: Test - Debug--------------------
Compiling source file(s)...
Main.cpp
Main.cpp: In function `int strcmp(const char*, const char*)':
Main.cpp:7: warning: asm operand 3 probably doesn't match constraints
Main.cpp:7: error: impossible constraint in `asm'
Main.cpp:6: warning: `int __res' might be used uninitialized in this function
Test.exe - 1 error(s), 2 warning(s)
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
他的文章
看原图
赞赏
雪币:
留言: