【问题标题】:unknown type name 'uint32_t', MinGW未知类型名称'uint32_t',MinGW
【发布时间】:2012-01-21 14:19:56
【问题描述】:

我收到错误 unknown type name 'uint32_t' 并包含 stdint.huint8_t 不会产生错误,uint16_t 也不会。

我正在使用 MinGW 和以下 make-lines:

# Build for Windows under MinGW
#MINGWDBG= -DDEBUG -O0
MINGWDBG= -DNDEBUG -Os
#MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT
MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,windows $(MINGWDBG)
mingw:
    windres win32\res.rc win32\res.o
    gcc $(MINGWOPT) mongoose.c -lws2_32 \
        -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
    gcc $(MINGWOPT) mongoose.c main.c win32\res.o -lws2_32 -ladvapi32 \
        -o $(PROG).exe

代码:

uint32_t function(void) {
    return VALUE;
}

其中包括:

#include <stdio.h>
#include <string.h>
#include "mongoose.h"
#include "main.h"
#include <stdint.h>

【问题讨论】:

  • 提供 uint32_t 是可选的。更新你的盒子,你使用的是 16 位处理器。
  • 更新信息。不错的评论 Johannes Schaub :) 但实际上没有使用 16 位处理器。

标签: c windows mingw


【解决方案1】:

要回答我自己的问题,更改包含的顺序似乎可以解决问题。

【讨论】:

  • 标准标题可以按任何顺序使用,您在自己的标题中弄乱了一些东西。如果您自己的任何标头中提到了uint32_t,则这些标头中也必须包含 stdint.h。
  • 是的,可能就是这样。 includen-p 来自 main.c,而 main.h 有一个 uin32_t 变量。所以改变顺序解决了这个问题。
  • 在这种情况下,您应该考虑在此标头中包含 stdint!
【解决方案2】:

如果

#include "main.h"
#include <stdint.h>

没用,但是

#include <stdint.h>
#include "main.h"

确实,您的main.h 文件很可能依赖于stdint.h。这意味着您应该将#include &lt;stdint.h&gt; 添加到main.h

【讨论】:

    猜你喜欢
    • 2012-05-25
    • 1970-01-01
    • 1970-01-01
    • 2013-04-26
    • 1970-01-01
    • 2014-11-19
    • 2018-10-27
    • 2016-09-16
    相关资源
    最近更新 更多