c - 使用 typedef 结构时出现错误 'a value of type "X *"cannot be assigned to an entity of type "X *"'

标签 c struct compiler-errors typedef

这是我用于节点的结构...

typedef struct
{
    struct Node* next;
    struct Node* previous;
    void* data;
} Node;

这是我用来链接它们的函数

void linkNodes(Node* first, Node* second)
{
    if (first != NULL)
        first->next = second;

    if (second != NULL)
        second->previous = first;
}

现在 visual studio 在这些行上给我智能感知(较少)错误

IntelliSense: a value of type "Node *" cannot be assigned to an entity of type "Node *"

谁能解释一下这样做的正确方法? Visual Studio 会编译并运行它,它在我的 Mac 上也能正常工作,但在我学校的服务器上崩溃了。

编辑:我想过使用 memcpy,但这很简单

最佳答案

我认为问题在于没有名为 Node 的 struct,只有一个 typedef。尝试

 typedef struct Node { ....

关于c - 使用 typedef 结构时出现错误 'a value of type "X *"cannot be assigned to an entity of type "X *"',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15595449/

相关文章:

c - 指向结构体的指针,这还是指向结构体的指针吗?

c++ - 收到错误,但在 '{' token C++之前预期的unqualified-id

java - 在 Java 公历中设置区域设置

c - "typedef void (*__handler)(int)"是什么意思?

c - 从类型 'bignum' 分配给类型 'int' 时的类型不兼容

opengl - GLSL 编译失败

compiler-errors - 在 Magento 版本中运行 "composer update"时出现错误。 2.3.3,PHP 7.3.15

python - 直接从 C 调用 mpmath

c - AND 和 OR 运算符 c

c - int 数组的动态内存分配