如何使代码在Turbo C中可重用 [英] how to make code reusable in Turbo C

查看:74
本文介绍了如何使代码在Turbo C中可重用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在Windows XP的TC中工作,我想知道如何在TC中使代码可重用(如 printf 等),这需要 .h 文件包含在包含文件夹& LIB 文件夹中的各个 .lib 文件.以及如何制作此.lib文件.
如果有人知道,请帮助我.
谢谢.

Hi,
I am working in TC on window XP.I want to know how to make a code reusable in TC(like printf,etc.) which required .h file in Include Folder & respective .lib File in LIB folder. And how to make this .lib files.
Plz,if someone knows this,plz help me.
Thank You.

推荐答案

您可能想开始阅读
《布鲁内斯·埃克尔(Bruce Eckel)的C ++第二版思考-免费电子书第1卷》和《第2卷 [ ^ ].

您可能还需要阅读一些TC专用材料. tlib是使您可以将.obj文件组合到库(.lib)中的实用程序.

另一方面,我会真正考虑迁移到 Visual C ++ 2010 Express [
You may want to start out be reading the
Thinking in C++ 2nd Edition by Bruce Eckel - Free Electronic Book Volume 1 & Volume 2[^].

You probably need to read some TC specific material too. tlib is the utility that enables you to combine .obj files into a library (.lib)

On the other hand I would really consider moving to Visual C++ 2010 Express[^], it''s available for free too.

Regards
Espen Harlinn


将您的code.h文件保存到包含文件夹(C:\TC\INCLUDE\)中.现在,添加#include<<code.h>>之后,就可以像printf 函数一样使用它.您可以在该头文件中添加原型,以减少在主代码中添加原型.
TC3.0可能不支持构建/导出用户定义库(可能我不知道).
但是TC5.**支持这一点.因此,您可以在TC5中进行尝试.**.
Save your code.h file into include folder(C:\TC\INCLUDE\). Now you can use it like printf function just after adding #include<<code.h>>. You may can add the prototype on that header file to reduce adding prototype in your main code.
TC3.0 may not support to build/export user define lib(may I don''t know).
But TC5.** supports this. So you can try this in TC5.**.


您应该构建一个静态库.
Turbo C++ 3.0(对不起,我只有这个)具有应用程序"菜单,从中可以选择" Library "作为应用程序的输出.
如果您的Turbo C版本没有这样的菜单(或命令行链接器选项),则可以考虑使用更具更新性的IDE(例如,
^ ]免费提供.)

[更新,来源: Schild t的书" Turbo C-完整参考书",1988年(!)]
由于版本1.5Turbo CTLIB.EXE一起提供,因此您可以使用以下命令行构建自己的静态库:
You should build a static library.
Turbo C++ 3.0 (sorry I''ve just this one) has the Application menu, from wich you may select "Library" as the output of your application.
If your version of Turbo C has not such a menu (or command line linker option), you may consider to use a more update IDE (for instance Visual C++ 2010 Express Edition[^] that is freely available).

[update, source: Schildt''s book "Turbo C - The Complete Reference", 1988 (!)]
Since version 1.5, Turbo C comes with TLIB.EXE, hence you my build your own static library using the command line:
TLIB library_name [operator]module_name [operator]module_name ...


其中:

  • library_name 是您的库的名称(如果您未提供库名,TC将自动附加.LIB扩展名.).
  • operator 是以下之一:


    where:

    • library_name is the name of your library (TC automatically append the .LIB extension, if you didn''t provide one).
    • operator is one of the following:

      + adds the module to the library.
      - remove the module from the library.
      * extract the specified .OBJ file from the library.
      -+ replaces the module inside the library.
      -* extract the specified module file and removes it from the library.
      

    • module_name是目标文件的名称(如果未指定,则TC假定扩展名为.OBJ).

    • 这篇关于如何使代码在Turbo C中可重用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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