delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/13/15:17:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Function overloading ?
Date: Tue, 13 Apr 2004 15:10:26 -0400
Lines: 30
Message-ID: <c5hdv5$1mvj4$1@ID-227552.news.uni-berlin.de>
References: <c5guns$n1r$1 AT reader11 DOT wxs DOT nl>
NNTP-Posting-Host: user-uive8gv.dsl.mindspring.com (165.247.34.31)
Mime-Version: 1.0
X-Trace: news.uni-berlin.de 1081883430 1801828 I 165.247.34.31 ([227552])
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: en-us, en, de, fr, ru, zh, ja
In-Reply-To: <c5guns$n1r$1@reader11.wxs.nl>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

PT wrote:

> Following code fails to compile , ... declaration of C function 'int test()'
> conflicts with previous declaration 'int test(int*)'...
> 
> However when i place the function prototypes in the cpp file, it compiles
> and links.
> 
> Any idea?

You have told the compiler that test() is a C function, rather than a 
C++ function, and C functions don't overload:


> --- file: F1.cpp ---------------
> #include "f1.hpp"

[from F1.hpp]

> #ifdef __cplusplus
>    extern "C" {
> #endif

> int test(int *i);
> int test(void);

> #ifdef __cplusplus


Lose the extern "C" stuff.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019