Go中的条件编译 [英] Conditional compilation in Go

查看:109
本文介绍了Go中的条件编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用包装 ://golang.org/cmd/cgo/rel =noreferrer> CGo for ENet < a>。

当我试图在Mac上编译我的包装时,库更旧,并且接口略有不同。 99%的代码是相同的,只有几个C调用需要更改。



在Go中处理这样的问题的最佳做法是什么?

是否有一些方法可以执行条件编译或条件导入?

解决方案

Go没有条件编译或条件导入。处理C代码中的类型差异。



[Go]作者是否反对预处理?


I'm trying to write a Go wrapper using CGo for ENet.

When I tried to compile my wrapper on a Mac the library was older and had a slightly different interface. 99% of the code is the same just a few C calls need to change.

What is the best practice for dealing with a problem like this in Go?
Is there some way to do conditional compilation or conditional imports?

解决方案

Go does not have conditional compilation or conditional imports. Handle the type differences in C code.

Are the [Go] authors opposed to preprocessing?

这篇关于Go中的条件编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆