BSPLIB的外部主要声明返回错误

发布于 2025-01-21 23:52:07 字数 1413 浏览 4 评论 0原文

im设置bsplib( https://github.com/zefiros.com/zefiros-software/bsplib )在Windows系统(在VS代码中)上使用WSL。编译时,我会收到错误消息:

test.cpp:4:5: error: conflicting declaration of C function ‘int main()’
    4 | int main()
      |     ^~~~
In file included from /mnt/d/study/software/bsp/include/bsp/bspExt.h:30,
                 from /mnt/d/study/software/bsp/include/bsp/bsp.h:34,
                 from test.cpp:2:
/mnt/d/study/software/bsp/include/bsp/bspClass.h:59:12: note: previous declaration ‘int main(int, char**)’
   59 | extern int main(int argc, char **argv);

使用程序只是BSP的一个裸露示例:

#include <iostream>
#include "bsp/bsp.h"

int main()
{
    bsp_begin(bsp_nprocs());
    int s = bsp_pid();
    int p = bsp_nprocs();
    printf("Hello World from processor %d / %d", s, p);
    bsp_end();

    return 0;
}

汇编:

g++ -I/mnt/d/study/software/bsp/include -g -lpthread -o main test.cpp

对我的(非常有限的)知识,标题文件中的“ extern”应防止编译器将主标签标记为“重复” '我对某些BSPS功能最感兴趣,这是我的一类,可悲的是,该功能不包括安装上的任何支持。到目前为止,我已经完成了:

  • 复制回购中的include文件
  • 添加了汇编(-i flag)的包含路径和类脚本指示的-lpthread
  • 添加了配置的include路径(c_cpp_properties.json)[在有没有的情况下进行测试,

由于该错误的许多可能来源(编译器,WSL,库,配置,vs代码,我的愚蠢),我无法确定我的错误,我也无法找到我,我也无法找到,我也无法找到任何错误的差异]在线资源到该组合。

Im setting up the bsplib (https://github.com/Zefiros-Software/BSPLib) on a windows system (in VS Code) using WSL. When compiling I get the error message:

test.cpp:4:5: error: conflicting declaration of C function ‘int main()’
    4 | int main()
      |     ^~~~
In file included from /mnt/d/study/software/bsp/include/bsp/bspExt.h:30,
                 from /mnt/d/study/software/bsp/include/bsp/bsp.h:34,
                 from test.cpp:2:
/mnt/d/study/software/bsp/include/bsp/bspClass.h:59:12: note: previous declaration ‘int main(int, char**)’
   59 | extern int main(int argc, char **argv);

The program is used is just a bare example for BSP:

#include <iostream>
#include "bsp/bsp.h"

int main()
{
    bsp_begin(bsp_nprocs());
    int s = bsp_pid();
    int p = bsp_nprocs();
    printf("Hello World from processor %d / %d", s, p);
    bsp_end();

    return 0;
}

Compiled with:

g++ -I/mnt/d/study/software/bsp/include -g -lpthread -o main test.cpp

To my (quite limited) knowledge, the 'extern' in the header file should prevent the compiler from labelling the main as 'duplicate' of some sort. Im mostly interested in some of BSPs functionalities as part of a class of mine, that sadly does not include any support on the installation. What I've done so far:

  • Copied the include files from the repo
  • Added the include path to the compilation (-I Flag) and the -lpthread as instructed by the class script
  • Added the include path to the configuration (c_cpp_properties.json) [tested both with and without this, no difference]

Due to the many possible sources of that error (program, compiler, wsl, library, configuration, vs code, my stupidity) I cant determine where I am mistaken, nor am I able to find online resources to that combination.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文