本文介绍了如何在C中创建自己的头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图制作自己的头文件,但它不起作用 vim
说
I tried to make my own header file but it doesn't work vim
says
wget.h:2:2: error: invalid preprocessing directive #ifndef__WGET_H__
wget.h:3:2: error: invalid preprocessing directive #define__WGET_H__
wget.h:7:2: error: #endif without #if
我的代码是这样的:
//wget header file
#ifndef__WGET_H__
#define__WGET_H__
int my_wget (char web_address[]);
#endif /*__WGET_H__*/
对我来说似乎很好(我阅读的示例与我的示例非常相似),我不知道出了什么问题.有什么想法吗?
it seems fine to me (the examples I have read are much alike with mine) and I don't know what went wrong. Any ideas?
推荐答案
一切都正确,只是缺少了空间.
Everything is right , just the space was missing.
#ifndef __WGET_H__
#define __WGET_H__
int my_wget (char web_address[]);
#endif __WGET_H__
您通常会在标头文件中使用上述内容,因为在您的项目中,如果偶然(偶然)多次包含相同的标头,则像这样编写标头将确保它包含标头只有一次.
You would generally use the above , in header files , because , in your project , if you happen(by accident) to include the same header multiple times , then writing the header like this will make sure , that it includes the header only once.
这篇关于如何在C中创建自己的头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!