Click here to Skip to main content
15,887,411 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C2084 FUNCTION ALREADY HAS A BODY Pin
Richard MacCutchan18-Dec-16 21:48
mveRichard MacCutchan18-Dec-16 21:48 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
Peter_in_278018-Dec-16 23:09
professionalPeter_in_278018-Dec-16 23:09 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
Richard MacCutchan19-Dec-16 5:38
mveRichard MacCutchan19-Dec-16 5:38 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
leon de boer19-Dec-16 19:03
leon de boer19-Dec-16 19:03 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
Albert Holguin21-Dec-16 10:41
professionalAlbert Holguin21-Dec-16 10:41 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
leon de boer23-Dec-16 6:26
leon de boer23-Dec-16 6:26 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
Albert Holguin23-Dec-16 7:25
professionalAlbert Holguin23-Dec-16 7:25 
GeneralRe: C2084 FUNCTION ALREADY HAS A BODY Pin
leon de boer23-Dec-16 8:37
leon de boer23-Dec-16 8:37 
No you don't ... think about it and just rewrite what it expands to

This is what you have
typedef unsigned char BYTE;
void hex_to_ascii(BYTE *ipx, char *str, int num);  // forward declaration

#define BYTE char
void hex_to_ascii(BYTE *ipx, char *str, int num) {

};

Expanded removing BYTE and replacing the type that is in scope it becomes ... dead simple
Remember the macro is in the preprocessor which is why it always expands like this, and why the second BYTE is gone by compile time. The first BYTE remains (it is prior to the macro definition), and I strike it out and changed it to it's proper type.
void hex_to_ascii( (BYTE) unsigned char *ipx, char *str, int num);  // forward declaration

void hex_to_ascii(char *ipx, char *str, int num) {

};

Get it your forward prototype and function body no longer match.
Depending on the C compiler it can see it as
1.) Two different functions with the same name .. THAT IS AN ERROR
2.) The same function with mismatched or redefined types ... THAT IS AN ERROR

Which depends how good your compiler is and there is no standard answer to what it will say. It even depends if they are in the same files or not because the compiler is trying to guess what you are meaning to do. His example complicates it because he has an extern in a 3rd file which I think means the compiler doesn't have a clue whats going on it's got 3 prototypes probably only 2 matching.

As I said you are arguing about something that is easy to test and I have seen many times when joining multiple libraries together.
In vino veritas


modified 23-Dec-16 14:59pm.

QuestionMFC code to move a train in two directions Pin
Member 1289526213-Dec-16 19:17
Member 1289526213-Dec-16 19:17 
AnswerRe: MFC code to move a train in two directions Pin
CPallini13-Dec-16 21:22
mveCPallini13-Dec-16 21:22 
AnswerRe: MFC code to move a train in two directions Pin
jeron114-Dec-16 4:40
jeron114-Dec-16 4:40 
GeneralRe: MFC code to move a train in two directions Pin
Richard MacCutchan14-Dec-16 5:08
mveRichard MacCutchan14-Dec-16 5:08 
GeneralRe: MFC code to move a train in two directions Pin
jeron114-Dec-16 5:11
jeron114-Dec-16 5:11 
SuggestionRe: MFC code to move a train in two directions Pin
David Crow14-Dec-16 5:36
David Crow14-Dec-16 5:36 
AnswerRe: MFC code to move a train in two directions Pin
Chris Losinger14-Dec-16 11:00
professionalChris Losinger14-Dec-16 11:00 
AnswerRe: MFC code to move a train in two directions Pin
Gerry Schmitz14-Dec-16 12:21
mveGerry Schmitz14-Dec-16 12:21 
AnswerRe: MFC code to move a train in two directions Pin
Patrice T14-Dec-16 12:45
mvePatrice T14-Dec-16 12:45 
AnswerRe: MFC code to move a train in two directions Pin
Munchies_Matt30-Dec-16 7:35
Munchies_Matt30-Dec-16 7:35 
QuestionTiny Encryption Algorithm Pin
Rhonnn12-Dec-16 20:42
Rhonnn12-Dec-16 20:42 
AnswerRe: Tiny Encryption Algorithm Pin
Jochen Arndt12-Dec-16 20:55
professionalJochen Arndt12-Dec-16 20:55 
AnswerRe: Tiny Encryption Algorithm Pin
Patrice T14-Dec-16 12:39
mvePatrice T14-Dec-16 12:39 
QuestionKnow when a child popup dialog is opened Pin
_Flaviu11-Dec-16 23:06
_Flaviu11-Dec-16 23:06 
SuggestionRe: Know when a child popup dialog is opened Pin
Richard MacCutchan11-Dec-16 23:18
mveRichard MacCutchan11-Dec-16 23:18 
AnswerRe: Know when a child popup dialog is opened Pin
Jochen Arndt11-Dec-16 23:56
professionalJochen Arndt11-Dec-16 23:56 
GeneralRe: Know when a child popup dialog is opened Pin
_Flaviu12-Dec-16 1:38
_Flaviu12-Dec-16 1:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.