Hi Alex, <div>Thanks for the clarification. Sticking to plain C looks like a good option for</div><div>maintainable code in this case. But any future plans to refactor code to make</div><div>Crash compatible with CPP would be very helpful - as polymorphism/overloading</div>
<div>can be used to work with kernel structures and accessing their members.</div><div><br></div><div>Thanks and Regards, <br>Ratnam<br><br><div class="gmail_quote">On Mon, Jun 28, 2010 at 12:44 PM, Alex Sidorenko <span dir="ltr"><<a href="mailto:asid@hp.com">asid@hp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5">On June 28, 2010 03:16:32 pm Ratnam Tatavarty wrote:<br>
> Hi,<br>
> I am looking for a way to code/compile my Crash tool extension .so in CPP.<br>
> During compile step, I hit a name collision with "namespace" keyword upon<br>
> including defs.h. Does anyone try any CPP extensions before and if yes are<br>
> there any guidelines/suggestions about the required changes, compile<br>
> options? Any insights about Crash compatibility with CPP are greatly<br>
> appreciated.<br>
><br>
> Build errors:<br>
><br>
> defs.h:1917: error: expected identifier before ‘namespace’<br>
> defs.h:1917: error: expected unqualified-id before ‘namespace’<br>
> defs.h:1956: error: expected identifier before ‘namespace’<br>
> ...<br>
> defs.h:2967: error: expected unqualified-id before ‘typename’<br>
> defs.h:2967: error: abstract declarator ‘char*’ used as declaration<br>
> defs.h:2967: error: expected ‘;’ before ‘typename’<br>
<br>
</div></div>Hi Ratnam,<br>
<br>
I think that building extensions in C++ for crash should just follow the<br>
standard guidelines for linking C/C++ code together. This is relatively easy<br>
when main program is implemented in C++ - just put the needed headers in your<br>
C++ programs in<br>
<br>
extern "C" {<br>
...<br>
}<br>
<br>
sections. But in our case it is different - the main program (crash) is<br>
implemented in C. To make C++ work properly, you need to call special<br>
initialization subroutines explicitly (e.g. those for ctors and dtors). This<br>
is very compiler and library dependent. I remember doing such things on HPUX<br>
with aCC. I think the same can be done on Linux with GCC/G++ but it will<br>
depend on compiler version.<br>
<br>
Regards,<br>
Alex<br>
<font color="#888888"><br>
<br>
--<br>
------------------------------------------------------------------<br>
Alexandre Sidorenko             email: <a href="mailto:asid@hp.com">asid@hp.com</a><br>
WTEC Linux                      Hewlett-Packard (Canada)<br>
------------------------------------------------------------------<br>
</font></blockquote></div><br></div>