头文件找不到

刨冰雨 2010-07-16 09:39:12
小弟 win7 64 bit 装了 MinGw(如下) 老是找不到头文件。大虾们帮忙看看

D:\Code\CAndCPP>g++ --version
g++ (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


#define N 10

#include <dos.h>
#include <stdio.h>

int main(){
struct birthday{
int year;
int month;
int day;
};

struct {
long num;
char name[10];
struct birthday bir;
} stu[N];

struct date today;

int i;

for(i=0; i<N; i++){
scanf("%ld", &stu[i].num);
scanf("%s", stu[i].name);
scanf("%d, %d, %d", &stu[i].bir.year, stu[i].bir.month, stu[i].bir.day);
}

getdate(&today);
for(i=0; i<N; i++){
printf("%-8ld", stu[i].num);
printf("%-1s", stu[i].name);
printf("%-6d\n", today.da_year-stu[i].bir.year);
}
}





D:\Code\CAndCPP>g++ -o Sample8_24 Sample8_24.C
Sample8_24.C: In function `int main()':
Sample8_24.C:19: error: aggregate `date today' has incomplete type and cannot be
defined
Sample8_24.C:29: error: `getdate' was not declared in this scope
...全文
291 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ecsape 2010-07-16
  • 打赏
  • 举报
回复
试试:g++ -o Sample8_24 Sample8_24.C -ID:\Program Files (x86)\MinGW\include\
anniue 2010-07-16
  • 打赏
  • 举报
回复
看样子是没找到结构体Date的定义了,查找一下date结构体,定义在哪个头文件下,然后再引用进来。
G_Spider 2010-07-16
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 andy20050125 的回复:]
#include <dos.h>
#include <stdio.h>

这两个头文件不是都是C的吗?

struct date today; 这个结构体不是 dos.h 里面的吗?
[/Quote]

嘿嘿,TC都没问题,~~~~
刨冰雨 2010-07-16
  • 打赏
  • 举报
回复
#include <dos.h>
#include <stdio.h>


这两个头文件不是C的吗?

struct date today; 这个有错吗?
刨冰雨 2010-07-16
  • 打赏
  • 举报
回复
#include <dos.h>
#include <stdio.h>


这两个头文件不是C的吗?

struct date today; 这个有错吗?
owenalen525 2010-07-16
  • 打赏
  • 举报
回复
学习了!!
刨冰雨 2010-07-16
  • 打赏
  • 举报
回复
#include <dos.h>
#include <stdio.h>

这两个头文件不是都是C的吗?

struct date today; 这个结构体不是 dos.h 里面的吗?
hyztcy 2010-07-16
  • 打赏
  • 举报
回复
大哥,你自己写的头文件在哪呢?没声明的东西当然编不过去。。
G_Spider 2010-07-16
  • 打赏
  • 举报
回复
struct date today; 找不到结构体的参照
刨冰雨 2010-07-16
  • 打赏
  • 举报
回复
在 D:\Program Files (x86)\MinGW\include\ 目录下是可以找到 dos.h

但程序提示找不到、

环境变量也没问题D:\Program Files (x86)\MinGW\bin;
skyworth98 2010-07-16
  • 打赏
  • 举报
回复
你的头文件放在哪儿了?
如果不在当前目录下,或者默认库路径下,你就需要指明头文件路径
貌似是/I
langren919 2010-07-16
  • 打赏
  • 举报
回复
MinGw?没听过·······来学习的····
ecsape 2010-07-16
  • 打赏
  • 举报
回复
回14楼:
我觉得cygwin还不错,就是太庞大。
刨冰雨 2010-07-16
  • 打赏
  • 举报
回复
[ecsape]

这个不行的
g++ -o Sample8_24 Sample8_24.C -ID:\Program Files (x86)\MinGW\include\


[kazuhikolui] 说的对

仔细看了看 MinGW 的 dos.h 没有发现有关date的东西。

在WIN下有没有更完美的编译环境?



/*
* dos.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* DOS-specific functions and structures.
*
*/

#ifndef _DOS_H_
#define _DOS_H_

/* All the headers include this file. */
#include <_mingw.h>

#define __need_wchar_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */

/* For DOS file attributes */
#include <io.h>

#ifndef RC_INVOKED

#ifdef __cplusplus
extern "C" {
#endif

#ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */
#ifndef __DECLSPEC_SUPPORTED
extern unsigned int *_imp___basemajor_dll;
extern unsigned int *_imp___baseminor_dll;
extern unsigned int *_imp___baseversion_dll;
extern unsigned int *_imp___osmajor_dll;
extern unsigned int *_imp___osminor_dll;
extern unsigned int *_imp___osmode_dll;

#define _basemajor (*_imp___basemajor_dll)
#define _baseminor (*_imp___baseminor_dll)
#define _baseversion (*_imp___baseversion_dll)
#define _osmajor (*_imp___osmajor_dll)
#define _osminor (*_imp___osminor_dll)
#define _osmode (*_imp___osmode_dll)

#else /* __DECLSPEC_SUPPORTED */

__MINGW_IMPORT unsigned int _basemajor_dll;
__MINGW_IMPORT unsigned int _baseminor_dll;
__MINGW_IMPORT unsigned int _baseversion_dll;
__MINGW_IMPORT unsigned int _osmajor_dll;
__MINGW_IMPORT unsigned int _osminor_dll;
__MINGW_IMPORT unsigned int _osmode_dll;

#define _basemajor _basemajor_dll
#define _baseminor _baseminor_dll
#define _baseversion _baseversion_dll
#define _osmajor _osmajor_dll
#define _osminor _osminor_dll
#define _osmode _osmode_dll

#endif /* __DECLSPEC_SUPPORTED */
#endif /* ! __MSVCRT__ */

#ifndef _DISKFREE_T_DEFINED
/* needed by _getdiskfree (also in direct.h) */
struct _diskfree_t {
unsigned total_clusters;
unsigned avail_clusters;
unsigned sectors_per_cluster;
unsigned bytes_per_sector;
};
#define _DISKFREE_T_DEFINED
#endif

_CRTIMP unsigned __cdecl __MINGW_NOTHROW _getdiskfree (unsigned, struct _diskfree_t *);

#ifndef _NO_OLDNAMES
# define diskfree_t _diskfree_t
#endif

#ifdef __cplusplus
}
#endif

#endif /* Not RC_INVOKED */

#endif /* Not _DOS_H_ */

kazuhikolui 2010-07-16
  • 打赏
  • 举报
回复
因在MinGW 裡 dos.h中, 沒有定義 date
MinGW Include 中的東西有些會缺少了

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧