小编ely*_*hiv的帖子

斯坦福大学教程和GCC之间的冲突

根据这部电影(约38分钟),如果我有两个具有相同本地变量的函数,它们将使用相同的空间.所以下面的程序应该打印出来5.用gcc结果编译它-1218960859.为什么?

该程序:

#include <stdio.h>

void A()
{
    int a;
    printf("%i",a);
}

void B()
{
    int a;
    a = 5;
}

int main()
{
    B();
    A();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

根据要求,这是反汇编程序的输出:

0804840c <A>:
 804840c:   55                      push   ebp
 804840d:   89 e5                   mov    ebp,esp
 804840f:   83 ec 28                sub    esp,0x28
 8048412:   8b 45 f4                mov    eax,DWORD PTR [ebp-0xc]
 8048415:   89 44 24 04             mov    DWORD PTR [esp+0x4],eax
 8048419:   c7 04 24 e8 84 04 08    mov …
Run Code Online (Sandbox Code Playgroud)

c gcc memory-management

82
推荐指数
5
解决办法
4062
查看次数

在lisp中将数字转换为字符串

我试图找到一个lisp函数来在数字和字符串之间进行转换,经过一些googling后,我喜欢一个具有相同名称的函数.当我进入(itoa 1)SLIME打印时:

Undefined function ITOA called with arguments (1) .
Run Code Online (Sandbox Code Playgroud)

我该如何进行转换?

lisp common-lisp itoa

20
推荐指数
2
解决办法
2万
查看次数

c ++中的逗号运算符不计算第二个表达式

我写了以下代码:

#include <iostream>
using namespace std;

int f()
{
    cout << "f()" << endl;
    return 3;
}

int v()
{
    cout << "v()" << endl;
    return 4;
}

int main()
{
    int m = f(),v();
    cout << m << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我希望它打印:

f()
v()
3
Run Code Online (Sandbox Code Playgroud)

编译g++ -O0 test.cpp -o test.out并运行结果:

f()
3
Run Code Online (Sandbox Code Playgroud)

为什么省略对v的调用?(这不能做优化,因为我添加了标志-O0)

c++ comma-operator

15
推荐指数
1
解决办法
466
查看次数

指针指向LSB或MSB吗?

如果我有以下代码:

int i = 5;
void * ptr = &i;
printf("%p", ptr);
Run Code Online (Sandbox Code Playgroud)

我会得到i或MSB的LSB地址吗?
平台之间的行为会有所不同吗?
C和C++之间有区别吗?

c c++ pointers void-pointers

14
推荐指数
4
解决办法
6494
查看次数

为什么使用JLE代替JL?

我写了以下程序:

#include <stdio.h>

int main()
{
    int i = 0;
    for (; i < 4; i++)
    {
        printf("%i",i);
    }

    return 0;
} 
Run Code Online (Sandbox Code Playgroud)

我使用gcc test.c -o test.o它编译它,然后使用它进行反汇编objdump -d -Mintel test.o.我得到的汇编代码(至少是相关部分)如下:

0804840c <main>:
 804840c:   55                      push   ebp
 804840d:   89 e5                   mov    ebp,esp
 804840f:   83 e4 f0                and    esp,0xfffffff0
 8048412:   83 ec 20                sub    esp,0x20
 8048415:   c7 44 24 1c 00 00 00    mov    DWORD PTR [esp+0x1c],0x0
 804841c:   00 
 804841d:   eb 19                   jmp    8048438 <main+0x2c>           
 804841f:   8b 44 24 …
Run Code Online (Sandbox Code Playgroud)

c compiler-construction assembly

10
推荐指数
1
解决办法
610
查看次数

"a和a或b"的目的是什么?

我在ipython中遇到了以下代码:

oname = args and args or '_'
Run Code Online (Sandbox Code Playgroud)

那是什么意思?为什么不使用args or '_'

python ternary-operator

9
推荐指数
1
解决办法
395
查看次数

便携式python - 无法安装pip

我正试着点击我的USB驱动器.按照此网站上的说明进行操作,我下载get-pip.py并运行python get-pip.py(python位于环境路径中).不幸的是脚本通过错误.我已将日志文件上传到此处.错误本身是:

Exception:
Traceback (most recent call last):
  File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2251, in parsed_version
    return self._parsed_version
  File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2344, in __getattr__
    raise AttributeError(attr)
AttributeError: _parsed_version

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2259, in version
    return self._version
  File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2344, in __getattr__
    raise AttributeError(attr)
AttributeError: _version

During handling of the above exception, another exception occurred:

Traceback (most recent …
Run Code Online (Sandbox Code Playgroud)

pip portable-python

6
推荐指数
3
解决办法
1万
查看次数

如何从apache mod_mono获得有用的堆栈跟踪?

我在Ubuntu上运行apache服务器,我正在尝试运行一个asp站点.当我进入页面时,我得到一个带有以下堆栈跟踪的404:

at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0021a] in <dca3b561b8ad4f9fb10141d81b39ff45>:0  
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0  
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)  
at System.IO.File.OpenRead (System.String path) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0  
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.get_CompilerName () [0x00019] in <fa43aae1d96f44db88d3b8a258fd9425>:0  
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00168] in <fa43aae1d96f44db88d3b8a258fd9425>:0  
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00048] in <fa43aae1d96f44db88d3b8a258fd9425>:0  
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in <59be416de143456b88b9988284f43350>:0  
at System.Web.Compilation.AssemblyBuilder.BuildAssembly …
Run Code Online (Sandbox Code Playgroud)

apache asp.net mod-mono

6
推荐指数
1
解决办法
127
查看次数

在Visual Studio 2010表设计器中使用枚举

我正在使用VS 2010 pro中的表设计器设计数据库,然后使用SqlMetal生成代码.

我想enum在其中一列中使用a 作为类型.

这怎么可能?

database-design entity-framework sqlmetal visual-studio-2010

5
推荐指数
1
解决办法
678
查看次数

自定义自动生成的类的显示

我有一个数据库,并且创建了一些类来使用进行访问/管理SQLMetal。现在,我使用LINQ to SQL,并且想在数据网格视图中显示查询结果。当我这样做时,这些列将以我在数据库表中的列的名称命名,并显示所有属性。我知道我可以使用DisplayNameBrowseable属性来更改此属性,但是由于类是自动生成的,因此我不能只在需要的地方添加此属性。我想出了三种解决方法:

  1. 创建一个Adopter以采用我的课程。我仍然不确定您在这种情况下如何准确地采用采用者。
  2. 创建另一个程序,该程序将在添加属性的代码生成后运行。这似乎是一种hack,我更喜欢将功能和GUI分开,因此此方法处于保留状态。
  3. 使用MetaDataType属性。我无法使它正常工作,据我所知,这要求这些类和元数据类必须位于同一DLL中。

我该如何定制?还有另一种方法吗?我应该采取什么方式?

编辑:忘记提及:我正在使用winforms,但如果它将简化事情,我将转到WPF。

c# datagridview auto-generate linq-to-sql

4
推荐指数
1
解决办法
332
查看次数