Solved

VC++ nmake questions

Posted on 2001-06-13
6
710 Views
Last Modified: 2012-06-21
what is the meaning of
the following which is from makefile for VC++

.cpp{$(INTDIR)}.obj::
   $(CPP) @<<
   $(CPP_PROJ) $<
<<


is this compatible with GNU make?

thx
0
Comment
Question by:Phoebe
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6187054
The above is an inference rule - it has the form of

.fromext.toext:
commands

doc quote:
"The fromext represents the extension of a dependent file, and toext represents the extension of a target file. Extensions are not case sensitive. Macros can be invoked to represent fromext and toext; the macros are expanded during preprocessing. The period (.) preceding fromext must appear at the beginning of the line. The colon (:) is preceded by zero or more spaces or tabs. It can be followed only by spaces or tabs, a semicolon (;) to specify a command, a number sign (#) to specify a comment, or a newline character. No other spaces are allowed. Commands are specified as in description blocks."


'$(SYMBOL)' is a macro expansion

'<<' specifies an inline file, and '$<' refers to a dependant file in the project.

So, the rule mainly reads "create .obj files from .cpp files by using the command given in '$(CPP)' taking care of the dependant file specified in '$(CPP_PROJ)'"

And: No, this is not compatible with the BSD 'make'
0
 
LVL 86

Expert Comment

by:jkr
ID: 6187064
>> is this compatible with GNU make?

Sorry for the confusion, but GNU 'make' is actually BSD 'make', so the answer is still 'no'.
0
 
LVL 2

Accepted Solution

by:
abesoft earned 100 total points
ID: 6187622
Two part answer.... In this rule, there is a header (the first line) and a command.  

First, the header:

This rule is a "generic rule", to transform a .cpp file into a .obj.  To do the same thing in GNU make, you would use:

%.obj : %.cpp
        $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

The syntax is definitely different between the two, but they can (for the most part) do the same things.

Secondly, the command:
The rest of the rule says what to do to turn a .cpp file into a .obj.  It reads as follows:
  $(CPP) @<<
  $(CPP_PROJ) $<
<<

The @<< {filler} << syntax tells make to create a tempfile, write all of the {filler} into it, and then stick its name on the command-line after the @.  This will likely turn into:
  cl.exe @tempfile.000
MS uses the @foo syntax to make the compiler read in arguments from the named file.  Other compilers use other syntax, so check with your compiler.

Under UNIX, you don't need to worry about command-line length, so redirecting the command-line via a temp file isn't important.  If you want to do it, you can though.  Try something like:

%.obj : %.cpp
        echo $(CPP_PROJ) $< > args.txt
        type args.txt | $(CPP)
        del args.txt

(I'm using type instead of cat, and del instead of rm.  I assume that you are running the make under DOS, not UNIX.  You will need to tweak this for your actual OS.)

Hope this helps!
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:Phoebe
ID: 6190902

abesoft's answer is better.

although jkr's answer is helpful.

thank you guys for open my sense.
0
 

Author Comment

by:Phoebe
ID: 6219784
It should change to PAQ
0
 

Author Comment

by:Phoebe
ID: 6219790
It should be PAQ
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question