首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么在代码块中编写include语句有时是有效的?

为什么在代码块中编写include语句有时是有效的?
EN

Stack Overflow用户
提问于 2019-05-29 00:47:46
回答 1查看 39关注 0票数 1

我来自python背景,其中以下内容是有效的:

代码语言:javascript
复制
def f():
    import someLibrary
    someLibrary.libraryFunction()

因此,当我需要调试C代码时,我在函数中间写道:

代码语言:javascript
复制
void f(int param)
{
     int status;
     /* other code */
     #include <stdio.h>
     printf("status: %d", status);
     /* more code */
}

它像我预期的那样编译和工作。后来有人向我指出,这是不应该编译的,因为C预处理器确实取代了#include~ statement with the contents ofstdio.h`。那么为什么这是有效的代码呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56346814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档