小编Sam*_*uce的帖子

无效指针再次变为有效

int *p;
{
    int x = 0;
    p = &x;
}
// p is no longer valid
{
    int x = 0;
    if (&x == p) {
        *p = 2;  // Is this valid?
    }
}
Run Code Online (Sandbox Code Playgroud)

在指向它的东西被释放后访问指针是未定义的行为,但是如果稍后的分配发生在同一区域会发生什么,并且您明确地将旧指针与指向新事物的指针进行比较?难道也无妨,如果我投&x,并puintptr_t比较之前?

(我知道不能保证这两个x变量占据相同的位置.我没有理由这样做,但我可以想象一个算法,你可以使用一组绝对有效的指针来交叉一组指针指针,删除过程中的无效指针.如果先前失效的指针等于已知的好指针,我很好奇会发生什么.)

c undefined-behavior

26
推荐指数
2
解决办法
1320
查看次数

如何在运行时C#中搜索嵌入文件

是否可以搜索与特定搜索条件匹配的嵌入文件(例如*.xml).

我的代码目前(适用于我知道路径的文件)

var fileName = "PATH.sample.xml";
var assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(fileName);

StreamReader reader = new StreamReader(stream);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(reader.ReadToEnd());
Run Code Online (Sandbox Code Playgroud)

c# reflection .net-assembly

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

在C/C++应用程序中用于嵌入式SQL数据库的PostgreSQL的替代方案

搜索后似乎是唯一一个免费的SQL数据库,可以嵌入到C/C++应用程序中,是PostgreSQL.

还有其他具有许可许可的解决方案吗?在C/C++中从头开始写这个有多难,所以我可以编写自己的东西?

c c++ sql database

0
推荐指数
1
解决办法
1110
查看次数

PC-Lint Misra 10.1布尔表达式错误

PC-Lint版本9.00L查看此代码:

  typedef unsigned char boolean_t; //This is actually in a system header file.
  ...
  /* The rest is in the .c file I'm working on. */
  boolean_t booleanVal
  ...
  uint8_t maskedVal;
  maskedVal = 0; //real code has this assigned based on a bitwise-and
  booleanVal = ( maskedVal != 0U );
Run Code Online (Sandbox Code Playgroud)

并给出了这个错误:

booleanVal = ( maskedVal != 0U );
                                ^
"LINT: <filename> Note 960: Violates MISRA 2004 
Required Rule 10.1, Implicit conversion of integer to smaller type"
Run Code Online (Sandbox Code Playgroud)

我已-strong(B, boolean_t ) …

c lint misra pc-lint

0
推荐指数
1
解决办法
453
查看次数

标签 统计

c ×3

.net-assembly ×1

c# ×1

c++ ×1

database ×1

lint ×1

misra ×1

pc-lint ×1

reflection ×1

sql ×1

undefined-behavior ×1