Create your own C language function library

Source: Internet
Author: User

Http://www.vcworld.net/news/200911/091956.html

 

1. Now we have created two functions sub1 () and sub2 () into a function library file named mylib. Lib. The functions and parameters of the two functions are as follows: void sub1 (void); float sub2 (int I, float X) create a file named s1.c and s2.c respectively, run the TCC command to decompile them and generate two target files, s1.obj and s2.obj. Finally, run the tlib command to create the library file mylib. lib, and create the corresponding example Table file (the example Table file is mainly used to check the usage of the main function library). The command format is as follows:
TCC s1.c s2.c
Tlib mylib + S1 + S2, mylib. lst
Copy the generated mylib. Lib library file to the C: cLib directory of the standard library.

2. Create the initial document (assuming the name is myfunc. h) as follows:
Extern void sub1 (void );
Extern float sub2 (INT, float );
Copy the file to the C: cinclude directory.

3.ProgramIn the following example:
# Include <myfunc. h>
Main ()
{...
Call sub1 (), sub2 ();
...
}

4. Use the compile command TCC under turboc to edit and link the user program file and set the user program file name to my. C. Use the command format:
TCC-ic: cinclude

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.