Solved

Inline functions with VC++ 4.2

Posted on 1998-06-18
2
233 Views
Last Modified: 2010-04-01
Hi,

I would like to know how to get inline functions to work in VC++.

My header file contains...
int MyFunc( DWORD X );

The CPP source looks like this...
inline int MyFunc( DWORD X )
{
   return X * X;                      
}

Now other CPP files have include the header file with MyFunc decalartion. All the files and header files are part if the project.

When I compile, the compile succeeds, but a link error
Undefined external int __fastcall MyFunc....
is reported.

I am compiling with Maximise Speed, Pentium, __fastcall
settings.

Any suggestions as to how I can get inline functions working?

Thankx in advance,
Mark
0
Comment
Question by:mark_21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1166232
Yes, you need to have

inline int MyFunc( DWORD X )
{
   return X * X;                      
}

In your header file, NOT your source file.

0
 

Author Comment

by:mark_21
ID: 1166233
Thankx, that works great!
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

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