(GO) NMAKE study notes

Source: Internet
Author: User

1. Invoke NMAKE's basic syntax in the command line:

namke/f makefile/x StdErrFile [macrodefs] [targets]

Where makefile is the makefile file, the/x stderrfile is an optional parameter that stores NMAKE errors to the file StdErrFile.

2, the main grammar of makefile:

2.1 Notes

Makefile's comments begin with #, such as:

# Usage:nmake Clean (removes all intermediary files)
# Or:nmake Options (builds one library variant (see below))

2.2 Macros

An important part of Makefile is the macro. The macro in Makefile is similar to the macro in the C language, which is essentially a string substitution. Its syntax is simple, as follows:

Macro NAME = macro Value

Macro NAME = macro Value

VS pre-defined many macros, such as OutDir, you can redefine the macros in your makefile to overwrite the original values.

Macros can use environment variables, such as your system has a OPEN_SOURCE environment variable, and you can define macros like this:

Third_party = $ (Open_source)

The reference usage for a macro is $ (macro name).

2.3 Preprocessing Instructions

Makefile's preprocessing directives are similar to the C language preprocessing directives, and their common directives are as follows:

! Error string--Displays the wrong "string" and then stops execution with an error code of U1050

! Message string--Displays the string, which is typically used for information to display the C language of the #pragma message

! Include [<]filename[>]--contains makefile.

! If const--is established (not 0), then process! F and next! else or! The statement between endif

There are also such as! Ifdef macroname,! Ifndef macroname,! ELSE,! ELSEIF,! Elseifdef,! Elseifndef,! The meaning of the directives such as # endif and C language is consistent.

2.4 Description Block

Basic syntax:

Target: Dependencies

Command

3. Example

Create a new console program named Consoletest, create a new file named Consoletest.vc in the Consoletest directory, and enter it with Notepad:

1234567891011121314 all: ConsoleTest.exe# compilestdafx.obj: stdafx.cpp    cl -c -D_X86=1 -DWIN32 -D_DEBUG -D_CONSOLE -Istdafx.h stdafx.cppConsoleTest.obj: ConsoleTest.cpp stdafx.obj    cl -c -D_X86=1 -DWIN32 -D_DEBUG -D_CONSOLE -Istdafx.h ConsoleTest.cpp # linkConsoleTest.exe: ConsoleTest.obj    link /INCREMENTAL:YES /NOLOGO /subsystem:console /out:ConsoleTest.exe ConsoleTest.obj kernel32.libclean:    @-ifexist *.obj del *.obj

CL and link Brief:

Some common options for CL:

-C: Compile but not link

-D: Defines the preprocessor, such as-d_x86=1: Specifies compiling on the x86 platform,-d_debug: Defining the preprocessor _DEBUG,

-I: Included header file

The last parameter of CL is the compiled file.

Some common options for link are:

/incremental: Whether to enable incremental link, yes is enabled, no is not enabled,

/NOLOGO: Suppress the start copyright flag

/SUBSYSTEM: Specifies a subsystem that is typically two options on a PC Desktop program: Console (console program) and Windows (non-console program).

/out: Specifies the output file.

The last parameter of link is the obj file and library file that need to be linked.

Clean the @-if instruction below can be written like this:-if, whose run result is the same, but has the echo of the command. Also directly written: If, can be executed.

(GO) NMAKE study notes

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.