Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Conflicting names

Posted on 2000-05-14
2
Medium Priority
?
177 Views
Last Modified: 2010-04-02
I am having problems when trying to use macros having the same name as that of functions. Actually <windows.h> includes <windef.h>.  The min(a,b) and max(a,b) macros are defined in <windef.h>. On the other hand min() & max() functions are present in <valarray> an STL class  . So whenever this two files are getting included at the same time it is giving  an compilation error.

For example the following code will give compilation error

#include <windows.h>
#include <valarray>

int main(int argc, char* argv[])
{
 return 0;
}

Can any of you experts out there suggest a practical workaround / solution to this problem.
0
Comment
Question by:lshankar
2 Comments
 
LVL 6

Accepted Solution

by:
Talmash earned 300 total points
ID: 2809424
hi ,

you should turn to min/max function as sons of windows/valarry .

that mean , you should declare them as a built-in functions with appropriate authority
(private/public etc...) , in some C-books it is called as internal-methods of a structure/class
..

this will be more helpfully if you'll one day add <stdlib.h> which if I'm not wrong already
includes min / max regular functions of its own .

Talmash
0
 

Author Comment

by:lshankar
ID: 2810243
Could you elaborate with some code examples
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

824 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