home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!news.ai!ilh
- From: ilh@lcs.mit.edu (Lee Hetherington)
- Newsgroups: comp.lang.c++
- Subject: Re: risky inline
- Message-ID: <ILH.92Aug27180930@winnie-the-pooh.lcs.mit.edu>
- Date: 27 Aug 92 22:09:30 GMT
- References: <1992Aug27.142700@uni-paderborn.de>
- Sender: news@ai.mit.edu
- Reply-To: ilh@lcs.mit.edu
- Organization: MIT/LCS Spoken Language Systems
- Lines: 26
- In-reply-to: trachos@uni-paderborn.de's message of 27 Aug 92 12:27:00 GMT
-
- What's the big deal? You defined (in the header file) C::c() to have
- EXTERNAL linkage, but then never provided a GLOBAL definition. For the
- sake of linkage, inline is like static (and turns into that if the
- function is actually too big to be inlined). In the library, your
- definition of C::c() is not global. Why is that so unsafe (or surprising)?
-
- The real safety of inline over #define is that you still get type
- checking on the arguments and return value. You also get `overloaded'
- function names:
-
- inline int min(int a, int b)
- {
- return (a <= b) ? a : b;
- }
-
- inline int min(int a, int b, int c, int d)
- {
- int ab = min(a, b), cd = min(c, d);
- return min(ab, cd);
- }
-
- are two separate functions with the same `name'. Try that with #define.
- --
-
- Lee Hetherington
- ilh@lcs.mit.edu
-