Solved

Conflicting names

Posted on 2000-05-14
2
171 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 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

808 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