本文介绍了在Visual C ++ FILE与Cfile中编译LGPL C源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近有机会抓住一些MP2音频编码器源来使用

在一个小实用程序中我写的是支持Korg便携式

多轨数字录音机。它是LGPL C,我的项目是Visual

C ++。一些问题,例如使用C ++关键字的
变量,例如:新的和类 - 好的很容易

解决了。


最大的问题是文件I / O,C代码使用了很多


FILE * fp;


fp = fopen(" googble.mp2"," rb);


等等


我是否真的必须通过所有代码并说出CFile fp;

fp.Open(etc.etc。),或者在那里某种方式让原来的FILE

指针方法起作用?我只是遇到编译错误

遇到。


为了记录,我每2或3年写一次计算机程序,所以我是

相当生锈,可能是一个简单的问题。我希望。


我有点沮丧,因为FILE和相关的例程在这段代码中使用了所有

,并且鉴于它是开源我会的如果可能的话,尽量避免使用主要的

mod。


谢谢,


加里

Had a recent opportunity to grab some MP2 audio encoder source to use
in a little utility I am writing in support of a Korg portable
multitrack digital recorder. It is LGPL C and my project is Visual
C++. A few problems, e.g.

variables using C++ keywords, e.g. new and class - OK that was easily
solved.

biggest problem is file I/O, the C code uses lots of

FILE *fp;

fp = fopen("googble.mp2","rb);

etc.

Do I really have to go thru all the code and say CFile fp;
fp.Open(etc.etc.), or is there some way to get the original FILE
pointer method to work? I just get compile errors whenever this is
encountered.

For the record I write a computer program every 2 or 3 years so I am
pretty rusty on what may be a simple problem. I hope.

I am a bit daunted because FILE and associated routines are used ALL
over this code, and given it is open source I''d like to avoid major
mods if possible.

Thanks,

Gary

推荐答案




保持代码不变。 Visual C ++能够在C模式下编译
。不要试图''翻译''到C ++,你只是要求麻烦。如果我没记错的话,你所需要的只是你需要的b $ b扩展源文件的.c扩展名才能使VC ++编译为
而不是C ++。请参阅您的文档。


-Mike



Leave the code alone. Visual C++ is capable of compiling
in ''C mode''. Don''t try to ''translate'' to C++, you''re just
asking for trouble. If I recall correctly, all you need
is a .c extension on your source file to make VC++ compile
as C instead of C++. See your documentation.

-Mike





Mike,我忘了提到的是我正在使用这段代码

到已经是C ++的Visual C ++项目中。我读了一些关于混合C和C ++代码的文章,这些文章建议将所有的b / b源代码转换为C ++可能更容易。然而,C ++代码

和MP2编码器之间的接口可以限制为大约6个函数

调用。


我知道C ++在生成标签时会超出C / $
编译器的作用...在

C ++程序中调用C代码的任何方便提示?例如。我不知道我是否可以将一组obj

文件编译为C,另一组编译为C ++并将它们全部链接在一起,或者我应该将
制作一个dll对于C代码,或静态库等等。


感谢任何提示!


Gary



Mike, what I forgot to mention is that I''m incorporating this code
into a Visual C++ project that already IS in C++. I read some
articles on mixing C and C++ code which suggested that converting all
C source to C++ might be easier. The interface between the C++ code
and the MP2 encoder can, however, be limited to about 6 function
calls.

I know that C++ when it generates labels goes way beyond what a C
compiler would do... any handy hints on calling C code from within a
C++ program? E.g. I don''t know whether I can compile a set of obj
files as C, another set as C++ and link them all together, or should I
make a dll for the C code, or a static library, etc. etc.

Thanks for any hints!

Gary





正如你所做的那样已经看到了,这不一定是真的。通常情况下,最好不要把工作代码弄得很糟糕。


-


Pete Becker

Dinkumware,Ltd。( http://www.dinkumware.com


这篇关于在Visual C ++ FILE与Cfile中编译LGPL C源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 17:42