Solved

VC++ nmake questions

Posted on 2001-06-13
6
711 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
returning a dereferenced pts in C++ 10 158
Focus not getting shifted out of  editbox 2 66
is twain_32.dll cmpatible with windows 10 ? 10 184
How to convert MFC APP to Win32 APP. 19 93
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 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