Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » *.C and *.H aren't recognised as C++ files
*.C and *.H aren't recognised as C++ files [message #169726] Wed, 17 May 2006 06:39 Go to next message
Eclipse UserFriend
I can't manage to associate *.C and *.H files to C++ using Eclipse 3.1.2
and CDT 3.0.2.

I have tried to add new global file types under "preferences -> C/C++ ->
file types" (although *.C already exists as a valid C++ source file) and
also tried to define my own project file types under "project ->
properties -> file types -> use project settings", but in both cases when
I create a *.C file clicking file properties informs me that the file is a
C source file, and not a C++ source file as I have defined in file types
configuration.

This bug is keeping me away from using autocompletion in my C++ source
code.

Any help is welcomed.
Re: *.C and *.H aren't recognised as C++ files [message #169831 is a reply to message #169726] Thu, 18 May 2006 08:04 Go to previous messageGo to next message
Eclipse UserFriend
I am quite sure that the auto completion problem is not related
to the fact that the file properties shows "C Source File".
This is only due to the fact that the Eclipse content type mechanism
is case insensitive, but CDT is a bit smarter and distinguishes
between main.C and main.c when parsing and syntax highlighting
- or is the syntax highlighting also wrong?

You could try and rename a .C file to .cpp and look if the completion
works then.

Jorge Diaz wrote:
> I can't manage to associate *.C and *.H files to C++ using Eclipse 3.1.2
> and CDT 3.0.2.
>
> I have tried to add new global file types under "preferences -> C/C++ ->
> file types" (although *.C already exists as a valid C++ source file) and
> also tried to define my own project file types under "project ->
> properties -> file types -> use project settings", but in both cases
> when I create a *.C file clicking file properties informs me that the
> file is a C source file, and not a C++ source file as I have defined in
> file types configuration.
>
> This bug is keeping me away from using autocompletion in my C++ source
> code.
>
> Any help is welcomed.
>
Re: *.C and *.H aren't recognised as C++ files [message #169891 is a reply to message #169831] Fri, 19 May 2006 02:50 Go to previous messageGo to next message
Eclipse UserFriend
Syntax highlighting seems fine to me, but when I rename the file from
Test.C to Test.cpp everything seems fine and autocompletion does work.

I post the simple code I'm using to test autocompletion.

#include <stdio.h>
#include <string>
int main()
{
printf("Hello World\n");

std::string message = "Hi again";



return 0;
}
Re: *.C and *.H aren't recognised as C++ files [message #169899 is a reply to message #169891] Fri, 19 May 2006 02:53 Go to previous messageGo to next message
Eclipse UserFriend
With Test.cpp typing message.siz and pressing "Ctrl + space" autocompletes
to message.size().
With Test.C typing message.siz and pressing "Ctrl + space" says no
completions available.
Re: *.C and *.H aren't recognised as C++ files [message #169931 is a reply to message #169899] Fri, 19 May 2006 05:27 Go to previous messageGo to next message
Eclipse UserFriend
I can reproduce this with CDT 3.0.2 and Eclipse 3.1.
Could you create a bugzilla bug against CDT 3.0.2 and add the sample
code or add the additional information to your existing bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=142450.

Thanks,
Toni

Jorge Diaz wrote:
> With Test.cpp typing message.siz and pressing "Ctrl + space"
> autocompletes to message.size().
> With Test.C typing message.siz and pressing "Ctrl + space" says no
> completions available.
>
Re: *.C and *.H aren't recognised as C++ files [message #170136 is a reply to message #169931] Mon, 22 May 2006 02:30 Go to previous messageGo to next message
Eclipse UserFriend
Ok Toni, I added the information to the current bug.
Re: *.C and *.H aren't recognised as C++ files [message #170386 is a reply to message #170136] Fri, 26 May 2006 15:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: henry.echelon.com

The released version of CDT won't even build C files in a C++ project.
Try using Eclipse Callisto and CDT 3.1.0.
Re: *.C and *.H aren't recognised as C++ files [message #173488 is a reply to message #170386] Fri, 21 July 2006 19:39 Go to previous message
Eclipse UserFriend
> Jorge Diaz wrote:
>> I think the problem has to be with capital letters in extensions, as
>> CDT mistakes the .C extension treating it as .c and consequently as a
>> C file instead of a C++ file.
>>
>> Anybody having the same problem?
>> Anybody knows the solution?
>>

Anton Leherbauer wrote:
> There is an Eclipse platform limitation about case insensitive content
> types (see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=105022),
> but as long as your CDT project has the C++ Nature, .C files should be
> handled as C++ code, even though the file Properties describe them as "C
> Source File".
>

Henry Luis wrote:
> The released version of CDT won't even build C files in a C++ project.
> Try using Eclipse Callisto and CDT 3.1.0.
>

Hi all,
I can confirm this problem and it's rather a serious problem, as it
prevents the Indexer/Search facility to work correct. It's still there
in the Version released with Eclipse Callisto

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=132201

As you can see from the change log, the bug has been fixed on the
CDT 4.x developement line. I just installed 3.1.0.200607170501
from the tar bundle to be found here:

http://download.eclipse.org/tools/cdt/builds/4.0.0/index.htm l

(Note this is not a "stable" build): The *.C files are still showed as
"C source file" in the properties dialog, but at least F3 ctrl-F3 are
working again, which is a big relief in a project with thousends of files...

Anyway, I would suggest to backport this fix to the stable line
if possible.

Cheers,
Hermann Vosseler
Previous Topic:CDT misleads .c and .C file types
Next Topic:Some system includes aren't searchable
Goto Forum:
  


Current Time: Mon Jul 14 10:18:20 EDT 2025

Powered by FUDForum. Page generated in 0.11130 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top