Solved

VC++ nmake questions

Posted on 2001-06-13
6
707 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now