getopt.h:编译的Linux C- code在Windows [英] getopt.h: Compiling Linux C-Code in Windows

查看:359
本文介绍了getopt.h:编译的Linux C- code在Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图得到一组九个* .c文件(和九个相关的* .h文件)在Windows下进行编译。

I am trying to get a set of nine *.c files (and nine related *.h files) to compile under Windows.

在code最初设计在Linux中使用采取标准的GNU Linux的/ C库getopt.h命令行参数。而该库并不适用于构建C- code在Windows中。

The code was originally designed in Linux to take command line arguments using the standard GNU-Linux/C library "getopt.h". And that library does not apply to building the C-code in Windows.

我想无视我的code,现在不和提出以下问题。对于那些你熟悉C语言库getopt.h:这将有可能建立和运行在Windows我的code。如果这取决于POSIX式的命令行参数?或将我必须重新编写code为Windows工作,通过输入文件的方式不同(和开沟getopt.h依赖)?

I want to ignore what my code does right now and ask the following question. For those of you familiar with this C-library "getopt.h": will it be possible to build and run my code in Windows if it depends on POSIX-style command-line arguments? Or will I have to re-write the code to work for Windows, passing input files differently (and ditching the "getopt.h" dependency)?

推荐答案

您是正确的。 getopt的()是POSIX,而不是Windows,您通常必须重新编写所有的命令行参数解析code。

You are correct. getopt() is POSIX, not Windows, you would generally have to re-write all command-line argument parsing code.

幸运的是,有一个项目,Xgetopt,这意味着为Windows / MFC类。

Fortunately, there is a project, Xgetopt, that is meant for Windows/MFC classes.

<一个href=\"http://www.$c$cproject.com/Articles/1940/XGetopt-A-Unix-compatible-getopt-for-MFC-and-Win32\">http://www.$c$cproject.com/Articles/1940/XGetopt-A-Unix-compatible-getopt-for-MFC-and-Win32

如果你可以在你的项目得到这个工作,应该编码和prevent你公平一点,您就无需返工所有的解析。

If you can get this working in your project, it should save you a fair bit of coding and prevent you from having to rework all parsing.

此外,它带有一个漂亮的图形界面的演示程序,你应该找到有用的。

Additionally, it comes with a nice GUI-enabled demo app that you should find helpful.

祝你好运!

这篇关于getopt.h:编译的Linux C- code在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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