[Geany-devel] C++ file-type extensions

Lex Trotman elextr at xxxxx
Wed Jul 8 22:38:16 UTC 2009


I'm a C++ programmer who only uses C to modify Geany ;-).

Nevertheless I have to agree with Enrico that if Geany cannot tell that a .h
file is C++ it should default to C.  Much of the open source software is
still C so it has precedence and volume on its side.  In general it is not
possible to tell if a header is C or C++, even for the compiler, which is
why extern C {} is there.  There has been past discussion in this ML of
looking for VIM and Emacs file marks in the first line but these are not
universal either.

It is unfortunate that C++ originally used .h for files that are not
backward compatible and that the main reference on C++ (Stroustrup) still
touts .h for C++ headers.  New C++ should use .hpp, so that tools and humans
can easily tell that this header is not C.  Then if you include a .h in your
C++ (for a library or such) then you know to wrap that header in extern C
constructs.

But of course there is already much existing C++ software out there that
uses .h.  If you can't change the extension or use some other way of marking
it, then I'm afraid that the only solution is going to be manually choosing
the filetype or changing your personal default.

I don't think that it would affect the build-system per se, but the default
command will of course change with the filetype, so C headers would default
to the C++ compiler command.  That shouldn't do any damage but might not be
helpful to users.

Cheers
Lex

2009/7/9 Enrico Tröger <enrico.troeger at uvena.de>

> On Wed, 8 Jul 2009 16:46:59 +0200 (MEST), Yves wrote:
>
> >
> >----- original message --------
> >
> >Subject: Re: [Geany-devel] C++ file-type extensions
> >Sent: Wed, 08 Jul 2009
> >From: Frank Lanitz<frank at frank.uvena.de>
> >
> >> Am Mittwoch, den 08.07.2009, 15:18 +0200 schrieb Yves Pausch:
> >>
> >> > As I have problems attaching the patch I provide a link instead:
> >> > http://www.ype.de/files/geany_cpp.patch
> >>
> >> At least for .h file this would introduce wrong behaviour as header
> >> for C++ should be either .H or .hpp. Nevertheless this is something
> >> you can configure on your end. Just have a look onto
> >> http://www.geany.org/manual/current/index.html#filetype-extensions
> >>
> >> Cheers,
> >> Frank
> >
> >--- original message end ----
> >
> >The new behaviour wouldn't imho be wrong only different from the
> >existing. I don't see any drawbacks while handling C headers in the
> >same way as C++ headers apart from it isn't completely precise. Most
> >of the C++ projects that I know or I'm involved into name their
> >headers *.h and commonly only template class declarations will be put
> >into *.hpp there. Bye, Yves.
>
> And what about the other tousands of C projects around? They loose
> syntax support for their headers files by default.
>
> Really, changing *.h from C to C++ is a no go. You already know how you
> can handle that for your own configuration. We won't change that in
> Geany. So, I agree fully with Frank and Colomban.
>
>
> Not sure about *.ipp, never heard of it.
>
> Regards,
> Enrico
>
> --
> Get my GPG key from http://www.uvena.de/pub.asc
>
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20090709/8e829d1f/attachment.html>


More information about the Devel mailing list