Re: [AutoTrace] C versus C++
- Wolfgang, sorry to be late to answer.
(I've CC'ed to autotrace ML.)
> > > - I should accept INLINE macro bacause gcc supports inline asAfter thinking, I'd like to introduce glib for this inline issue.
> > > an extension of C lang. (Glib has INLINE macro, so it is worth
> > > to use glib. But this is another issue.)
> OK, to what concerns the macro.
Here is my approach:
(1) If the user has not installed glib, autotrace doesn't use inline.
(2) If the user has installed glib, autotrace uses glib ;and enable inline.
(3) configure checks the existence of glib.
(4) libautotrace and autotrace.h will not depends on glib.h.
> > > - I should not accept REF(T) macro because it is not realy needed.I understand why C style is ugly.
> > > C lang can do same with * pointer operator:).
> > > If it is possible to do a thing with C lang without C++ lang,
> > > I think we should do it with C lang.
> Here I have a different opinion. But this is not a language issue, it
> is a style issue. In C++ I'm used to use references (refs) whenever I
> to pass a value to some function and don't expect that that function
> needs the address of the value. Example: add to value and return the
> result. Using a pointer here is quite unnatural. It is only a very ugly
> workaround for fixing a performance problem due to the non-availability
> of references in C. But for C I would recommend to keep the current
> value passing style as it is much clearer code and the performance
> are not to high (in C mode and for the small structs that we have in
> If you use a pointer you cannot read from the code what happens with the
> ownership (who does the free?) of the piece of memory the pointer points
> to. Is it transferred or not. You need to get this info from some other
> documentation. On the other hand using a value (and in C++ for
> reasons a reference) makes this very clear directly in the code without
> any need for further documentation.
> Using refs vs. values may have also an impact on inline expansion.
> It is easier if refs are used.
But as a user of libautotrace.a,
I don't like to consider there is two version of libautotrace.a:
libautotrace.a compiled by C compiler and libautotrace.a compiled
by C++ compiler.
How do you think that we introduce that passing value via a pointer
I think the memory storage ownership is small problem if we define
rules about memory storage handling. If it is difficult to define
simple rules, we can introduce reference count mechanism well used
in GtkObject system.
> Finally: What about the const correctness? Do you consider that useful?If the C-lang-compatible, we should keep all correctness, I think.
> And what about the memory problem that I wrote about in my message to
> group? Martin - did you check the "uninitialized variable" messages of
> FlexeLint? I think they are (small) bugs.
Wolfgang, I'd like you to get a write account for autotrace CVS