changing extension to .mm can't find the header anymore - c++

I am working on a Iphone Application. I need to use C++ code inside MainViewController class. For that I renamed the MainViewController.m to MainViewController.mm in order to accept C++ code.
However after doing that it looks like it lost the link with the MainViewController.h file. I can no longer synthesize properties declared in the .h file and can no longer create action in the header file. It can't find the .mm file. and if I try to "Jump to definition" it says Symbol not found
How can I fix that. Thank you for any help

Close and reopen the Xcode project
if that fails, Build and remove any errors which may have been introduced as a result of changing the type to compile as.
if that fails, Clean All and rebuild.
if that fails, got to the Organizer, choose "Projects" > *YOUR_PROJECT* and Delete its Derived Data.

Related

Xcode 11 header file issue

I'm pretty new to using Xcode with C++ development. For some reason, the compiler isn't treating .h files correctly. It doesn't color code correctly, nor does it highlight compile-time errors. I've tried looking through the settings to see if I can change this, and I found that it treats .h files by default as c-headers. I changed this to C++ header file in one of them to see if this would help, and then closed the project and reopened. Nothing.
Maybe try to rename your files to .hpp ?

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.

Eclipse-PDT: change the include folders

I'm using Eclipse-PDT with a kind of cross-gcc(gcc customized to compile the program) in Linux. The problem is, when I included a header file in the source code, e.g. #include <stdbool.h>, Eclipse would try to find the file under the folder /usr/lib/gcc/x86_64-linux-gnu/4.9/include, but I hope Eclipse to find the customized header file, which is under another foler: /home/user/crossgcc/lib/gcc/i686-elf/4.9.2/include. I've tried to change a lot of settings, but it didn't work still. How to do the trick?
I found it. Right click the project and select Properties, delete the original ones and add yours.

Visual Studio 2008 C++ won't compile changes in header class

I have a very strange problem in Visual C++ 2008:
My project contains some classes which I'm developping and I'm not including to precompiled header stdafx.h as they are not still finished (EDIT they are included in the main.cpp file, after stdafx.h)
When I make changes in a class which has .h and .cpp files, the changes are applied correctly.
When I make changes in a class which only has a .h file, VC2008 detects errors in there, but if all goes right, it runs the program and the class is not updated. A prove of this is that if I set a breakpoint somewhere in the class, it doesn't stop there and the breakpoint appears with a warning saying that "there is no executable code associated with this line".
EDIT I tried to include the header file in stdafx.h and the behaviour is the same: changes are not applied.
What I'm doing right now is to clean the project before running again. Sometimes I loose lots of time if I forgot to clean because I have to reach large process to reach and test the changes, then I see I can't debug and have to stop, clean, run and reach changes!
Any solution to not have to clean the project once and again?
Just for curiosity I went deeper in this issue. Very weird behaviour:
When changes are made only in a private class member function from a header class with no .cpp file, which is included in stdafx.h (precompiled), then compiler won't apply changes!!
This won't apply if changes are made in the constructor, public methods, variable or in sub-struct/class definitions.
If this makes sense for someone it would be really good a clear explanation.

Managed C++ - ignored Header file

So I’ve got a HEADER(.h) and a SOURCE(.cpp) file in a Managed C++ VS2010 solution.
My solution builds successfully even though I added garbage to the header.
public:
someConstructor(); // assume the syntax is good here
asdf // garbage
Why I did this
My original problem was that I couldn't update my CPP file to add a new constructor. When I added a new constructor to my CPP file, my solution failed to build due to a non-existent overridden member function, i.e. my new constructor. I added garbage to the HEADER file to make sure that VS2010 was actually reading my HEADER file. Obviously it was not.
How can I make sure that VS2010 looks at my HEADER file? It seems to be looking at another HEADER file...
Thanks
If you select the file(s) in question and open up the properties window (View->Properties Window) you can see if your project is looking at the correct file or not. Additionally, if the file is not being included in the build (even though it's in the solution), you can set Include in Project to true.
Note that I'm assuming you're using MSBuild. If you're using some other build system, there may be a different procedure for ensuring the build is using the correct header file.