gpt4 book ai didi

c - 错误: Stray '#" in program (SWIG)

转载 作者:行者123 更新时间:2023-11-30 19:23:27 27 4
gpt4 key购买 nike

我正在使用 RHEL 6 并尝试使用 SWIG 编译一些代码。

SWIG 文件名为 mySwig.i,看起来像

   %module base_module
%{
#include "base.h"
%}
%include "base.h"

mySwig.i 文件保存在名为 foo 的文件夹中。文件夹 foo 还包含其他 .h、.c 和 .cxx 文件。

我使用的命令是

    gcc -fpic -c foo/*

输出为:

    foo/mySwig.i:1 error: expected identifier or '(' before '%' token
foo/mySwig.i:3 error: stray '#' in program
foo/mySwig.i:5 error: expected identifier or '(' before '%' token

有人知道如何解决这些错误吗?

最佳答案

gcc -fpic -c foo/* 将匹配 foo/目录中的所有 文件。您很可能只想匹配 C 文件。如果您确实愿意,可以使用 gcc -fpic -c foo/*.c 执行操作。

我个人建议使用 CMake 或 Autotools 之类的东西,甚至只是一个 Makefile 来构建项目,而不是直接调用 cc。

关于c - 错误: Stray '#" in program (SWIG),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11970332/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com