C ++ exports def file and exportsdef File

Source: Internet
Author: User

C ++ exports def file and exportsdef File
Https://msdn.microsoft.com/zh-cn/library/hyx1zcd3 (v = vs.80). aspx EXPORTS

Introduces a section composed of one or more definitions (exported functions or data. Each definition must be on a single row.

EXPORTSdefinitions

Remarks

EXPORTSThe keyword can be on the same row or the previous row where the first definition is located .. Def files can contain one or moreEXPORTSStatement.

The syntax for exporting definitions is:

          entryname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA]

EntrynameIs the name of the function or variable to be exported. This is required. If the exported name is different from the DLL nameInternalnameSpecify the name exported from the DLL. For example, if the DLL exports a functionFunc1 ()To use itFunc2 (), You should specify:

EXPORTSfunc2=func1

@ Ordinal: Specify the sequence number instead of the function name to enter the DLL export table. This helps minimize the DLL size .. The LIB file will contain the ing between the serial number and the function, which allows you to use the function name as usual in a DLL project.

OptionalNONAMEThe keyword can only be exported by serial number, and the size of the exported table in the result DLL is reduced. However, if you want to use GetProcAddress on the DLL, you must know the sequence number because the name will be invalid.

OptionalPRIVATEDisableEntrynameImport data to the database generated by LINK. It is invalid for exporting images generated by links.

OptionalDATAKeyword specifies that the exported data is not the code. For example, you can export data variables as follows:

EXPORTSi DATA

When the same export is usedPRIVATEAndDATA,PRIVATEMust be locatedDATA.

There are three methods for exporting definitions, which are recommended in sequence:

All three methods can be used in the same program. LINK also creates Import and Export files when generating programs that contain export, unless the. exp file is used in the generation.

The following is an example of the EXPORTS section:

EXPORTS   DllCanUnloadNow      @1     PRIVATE   DATA   DllWindowName = Name        DATA   DllGetClassObject    @4 NONAME   PRIVATE   DllRegisterServer    @7   DllUnregisterServer

Note: when using the. def file to export variables from the DLL, you do not need to specify_ Declspec (dllexport). However, in any DLL file, it must still be used in the data declaration._ Declspec (dllimport).

Related Article

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.