Weird "braces" file type - Eclipse C++ - c++

I'm a beginner in C++ and in Eclipse, but I have a weird problem. My source and header files seem to act differently whether I imported them from someone or created them myself.
When I import a C++ file (header or source file) in my Eclipse IDE, the icon of the files on the window bar looks like this :
However, when I create a file on my own (File -> New -> Source File / Header File), the icon of the files I created look like this:
These files work the same as the first ones, the compiler works and the code executes properly, but it feels like Eclipse is considering the second files are in some way different from the first ones. I think this is causing some issues in the way Eclipse treats the syntax and coloring policy of my files, applying the policy to the first type of files and not to the second.
On the Project Explorer though, every file look the same :
Thank you in advance !

Related

VS Looks for Headerfile in Debug folder

I am really new to C++ and in haven't worked with VS in a long time.
My problem is, VS suddenly throws me an error when I try to import one of my header-files that is in the same folder as the cpp file I try to import it in.
Maybe I hit some Keycombo or klicked on a "bad" button ^^
I also checked my "Additional Includes Folder"-Setting it only points to my other projects src folder. If I clear the value it the error still persists.
I feel like its weird that VS looks for the header in the Output folder (but it's also looking for a .tlh whatever that is)
Thanks :)
Just change #import "Game.h" to #include "Game.h".
Import directive is used for type libraries not header files.
Keeping in mind the fact, these files (tlh) are generated by the compiler, so its actually not weird that VS looks them in output folders.

What is the difference between a cbp file and a cpp file?

In code blocks their default file is main.cbp so I usually change it to main.cpp. But there doesn't seem to be a difference between their performances. But then again I just began coding in C++ so I'd like to know if there are any differences before I get too deep.
.cbp is the extension for a codeblocks solution file. Usually the project file will contain the .cpp file. chp files dont contain the actual source code but the procedure for codeblocks to associate files.
In a nutshell, .cpp contains the source code while cbp files dont.
Why do you have to know about that?
Answer: when passing source code, cpp file is the only format that can be opened for IDE other than codeblocks eg. Dev C++

QtCreator - Compiling issue - External source files

I have a Qt project, accessing another cross-platform (boost) project on my disc. Adding the header includes does not seem to cause any problem.
#include "../../Visual Studio 2015/Projects/..." //Header file down the road
Adding existing source files to the sources folder in my Qt Project works also without a problem, the files are found and I can open them. I believe the files are not correctly compiled - if at all - as I get a linker error, telling me that %sourcefile%.obj could not be opened. (not created)
LNK1104: cannot open file 'debug\Error.obj'
I tried copying the content of Error.cpp into a new .cpp file created in the Qt project directory. After that the error message jumped to the next source file. I could now do this for all source files, but this seems to be quite... unhandy. Changes in the original project won't affect the Qt project then.
Does somebody know the problem / got a solution to it ?
I checked this question, answer and comments already, but that did not seem to fix the error or change anything.
The solution was quite simple and a little strange. It appears that something is causing an issue when using paths with spaces with Qt's include(...) and SOURCES in a *.pro file.
//This apparently works and source files are compiled.
include(C:/ProjDir/ProjName.pri)
//This works too, but the source files are not being compiled.
include("../../Visual Studio 2015/Projects/ProjDir/ProjName.pri")
Thanks to JKSH on the Qt-Forums and Sebastian for his hint using a .pri file.

netbeans can't find C++ header file in same directory

In one particular cpp file (abc.cpp), when I ask to navigate "to Declaration/Definition", it says "cannot open element "abc.h"". This functionality works for other header files. This in itself is not a big problem, but it also means that auto-complete and syntax highlighting doesn't work for this file.
Some extra info:
The header file is in the same directory as the cpp file and both are included in the active netbeans project
I was able to enter the header file name with auto-complete, i.e. #include "ab<ctrl-space>"
clicking the "Go to header/source" button works both ways for this cpp/h pair.
right-clicking on the class name in the header file, and then selecting "go to source" brings me to the cpp file, as usual.
in other cpp files the connection to the header file is working fine, as is autocomplete & syntax highlighting
netbeans has a green square in the top right of the header file window, indicating "no errors"
I have tried deleting my cache as explained here
I'm using netbeans v8.0.2 on OpenSuse 13.2
Here are some ideas:
Sometimes the Code Assistance is not as good for projects that Netbeans didn't create from scratch. If it is not a complicated Makefile, it might be worth it to create a new project with the C/C++ Application type and copy over and then add each source and header file.
The code assistance depends on analyzing he log from the build each time, so sometimes just rebuilding the project will fix the code assistance.
There are a number of options if you right click the project under the code assistance sub-menu.
Edit the Makefile to make sure this file is being compiled in the same way as the other files that work. It may be getting compiled with different options because it was added later and therefore not providing the same info for code assistance. You will need to rebuild after making these changes for them to have an effect.

Netbeans-specific C++ error "Undefined reference to XXX" - (Solution posted)

I wrangled with this problem for a good 5 or 6 hours, pulling my hair out until I finally found a solution. I wanted to post this (not sure if there is a specific place to post solutions to unasked questions) as a solution for others who may run into the same difficulty.
I am coding a C++ project in Netbeans 7.1.1 running on Linux Mint Lisa, and kept on getting an "Undefined reference to XXX" error when trying to use a static variable. Coming from a background in C# and thus not very familiar with header files and the like, I searched for hours expecting to find a problem with the way I declared my variable or my class. I couldn't find anything...
Go to your nbproject folder in the files explorer in Netbeans. Open up the configurations.xml file. Scroll down to the logicalFolder tag with the attribute name="SourceFiles". Make sure that all your .h and .cpp files are included as itemPath tags within the logicalFolder tag! Netbeans correctly added some, but not all of my cpp and h files, hence the problem. Not sure why there would be this inconsistency, as all class and header files were added through the same Netbeans wizard. Anyways, with the configurations file changed, the makefiles were then updated and written correctly on the next build and all functioned as expected. Hope this can help somebody!
Just to add more details to Levi's answer (for anyone newish to this like me), click the "Files" tab on the left of the screen, where your list of files and folders is. This gives you a different list of files than the "Project" tab does.
Expand your project folder if it isn't expanded already. One of the resulting folders is "nbproject." Expand the folder. This is where configurations.xml is.
In short:
Files tab > nbproject > configuration.xml
However, adding the .h files to configuration.xml did not work for me.
In my case, I only had to include the source files as #include lines within other source files to make it work ... I could compile the individual source files without error, but the project was another story. Once I added the #include lines in other source files that required certain methods to be found, then it all worked as planned. Hope this helps someone.