|
| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
Body already defined error in C++
|
Original Message
|
Name: Amit Lal
Date: September 25, 2002 at 09:41:15 Pacific
Subject: Body already defined error in C++ OS: Windows XP CPU/Ram: 128MB
|
Comment: Hi, I have a C++ application to compile. I am using Borland Builder 6 for the same. I have a template function defined and then same function for a specific class in same file one below the other. It is like : template bool AuditRecipient::action(const Notification* note, const T* item) { if (is_auditable(Db_event(note->get_event())) && (alevel != none)) { System system; system.new_audit(alevel, //get_event_as_string(Db_event(note->get_event())), AuditOper::asCString(eventToAuditOper(Db_event(note->get_event()))), Db_table::get_name(), "", "", &Db_table::record, Db_table::get_col_bindings(), Db_table::get_col_count(), ""); } return true; } // Next definition specifically //for Stock_quantity class bool AuditRecipient::action(const Notification* note, const Stock_quantity* item) { if (is_auditable(Db_event(note->get_event())) && (alevel != none)) { // We have to audit this operation System system; string idstr; if (!getid(idstr)) idstr = "DEFAULT"; system.new_audit_stock(idstr, //get_event_as_string(Db_event(note->get_event())), AuditOper::asCString(eventToAuditOper(Db_event(note->get_event()))), *item); } return true; } Borland compiler is giving error given below: [C++ Error] AUDITCB.CPP(116): E2171 Body has already been defined for function 'AuditRecipient::action(const Notification *,const Stock_quantity *)' Any suggestions to this problem are welcome. Thanks, Amit Lal
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Jeff J
Date: September 25, 2002 at 14:07:24 Pacific
|
Reply: (edit)It looks as if you are implementing a template specialisation for the original member function. If so, just preface the specialisation with //nothing between angle brackets... template < > and the compiler will treat it as a special case, where T is specifically an object of type Stock_quantity. C++Builder is very good with templates, so it should handle the change gracefully. The only reason the extra code is required, is that without it, the compiler thinks you want to redefine the original templatised function with a non-templatised one. By adding the blank template list, you are telling the compiler "just add this special case to the list of templated options". Cheers
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Amit Lal
Date: September 25, 2002 at 16:19:35 Pacific
|
Reply: (edit)Thanks for the reply Jeff. But, my problem hasn`t solve completely. Now, compiler is giving internal compiler error at the end of the function body. Precisely, [C++ Fatal Error] AUDITCB.CPP(128): F1004 Internal compiler error at 0xc65566 with base 0xc10000 Any insights ? Thanks and Regards, Amit Lal
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Jeff J
Date: September 25, 2002 at 18:29:09 Pacific
|
Reply: (edit)It is hard to tell since I'm not sure exactly what line 128 is now, what with the squishing of code on this forum and any changes made. At a guess, I would think it would have to do with the pointer item, since its declaration would vary between the two versions of the functions. Can you isolate what is now on line 128, and what new_audit_stock is expecting for parameters?
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Amit Lal
Date: September 26, 2002 at 08:28:09 Pacific
|
Reply: (edit)It looks ok Jeff. new_audit_stock signature is - Db_const_iterator new_audit_stock(const string& refid, const string& oper,const Stock_quantity& qty) const; Also, line number 128 is the closing brace of the method,'}'. Regards, Amit Lal
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Jeff J
Date: September 26, 2002 at 12:28:33 Pacific
|
Reply: (edit)Definitely strange. I looked up F1004 in Google, and saw a few suspicious hits, but mostly with BCB4, not 6. However, many seem to refer to precompiled headers, which have been known to cause problems at times. Just for laughs, try shutting BCB down, deleting the precompiled headers file, and then doing a full rebuild. Sometimes it works. The error does not seem to be related to coding per se, but an internal problem with the compiler. Try searching Borland Community and the bug reports; maybe there's more on it there.
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Programming Forum Home
|
|
|