golang/go

cmd/cgo: inject preamble before other include directives

Open

#35,315 创建于 2019年11月2日

在 GitHub 查看
 (17 评论) (0 反应) (0 负责人)Go (19,008 fork)batch import
FeatureRequestNeedsInvestigationcompiler/runtimehelp wanted

仓库指标

Star
 (133,883 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Yes

What did you see?

The cgo generated file _cgo_export.c includes stdlib.h before anything else (see here). It precludes the possibility to use some "include first" headers without errors or warnings, such as Python.

From the Python docs:

Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included.

Cgo should allow to inject a C preamble before any other include directive.

贡献者指南