Xcode 11 completion behaviour for project in C++ - c++

I'm struggling to change the behaviour of auto-completion for my own project in Xcode11.
I selected an empty project and I have implement some C++ methods. Now I want Xcode to recognize these methods and show the auto-complete suggestions for them.
However, I am only getting completion suggestions for basic C++ code, e.g., if-else, switch case, etc.. How can I setup Xcode to recognize my own methods?
Besides, in an older Xcode version I got auto-complete suggestions for previously written text in the same file. This functionality is gone. Can I reactivate it somehow?
Cheers

Your project should index and make those methods available in auto-completions. I've had similar issues (currently Xcode 11.3.1), but I found that building the project once (even with just a boilerplate main function), quitting and restarting Xcode seemed to help, at least for the project-local classes & methods. However auto-complete is broken now for some parts of C++, as if the standard system search paths for C++ aren't getting indexed. For example, completions for standard C++ header #includes (e.g. ) don't appear, only various Apple C lib headers. It may be that manually adding these paths to the build settings could resolve them. It used to "just work" though.
I'd also recommend filing a bug report if you haven't already. I'm sure they're focused mostly on Swift these days but if enough reports come in they may fix it.

Related

How to get wxWidgets working in Visual Studio 2012

I've got a problem for which I would very much like a solution please:
All I'm trying to do is use wxWidgets in Visual Studio 2012 (in C++), and make it accessible to my code project. That shouldn't be so hard, should it? But as usual, even though there are programming tutorials for it, wxWidgets is evidently one of those things that has no proper documentation just to simply get it running, or if it does then I sure can't find it.
I downloaded the installer for Windows and installed it. When it finished, it gave me a message that said:
wxWidgets was installed successfully!
Please note: before using wxWidgets in your application,
you must build the library using the same compiler you
use for building your program.
Please see docs/msw/install.md file in the installation
directory for the detailed instructions about how to build
wxWidgets and use it from your application.
It should be noted that I think I remember something on the website or somewhere saying that I can just include a header file into my project and forego the DLL altogether (which is what I'd prefer to do, if possible), though I may possibly be misremembering that or confusing it with something else.
Anyway, when I opened the docs/msw/install.md file, I found (amongst other things) these instructions:
--- From the IDE
Ready to use project files are provided for VC++ versions 8, 9,
10, 11, 12, 14, 15, 16 and 17 (also known as MSVS 2005, 2008, 2010, 2012,
2013, 2015, 2017, 2019 and 2022 respectively).
Simply open wx_vcN.sln (for N=8, 9, 10, 11, 12, 14, 15, 16 or 17) file,
select the appropriate configuration (Debug or Release, static or DLL)
and build the solution. Notice that when building a DLL configuration,
you may need to perform the build several times because the projects
are not always built in the correct order, and this may result in link
errors. Simply do the build again, up to 3 times, to fix this.
Of course, it doesn't even say WHERE the "wx_vcN.sln" files are, but I ran a file search and found them in C:\wxWidgets-3.1.6\build\msw and I opened the one called wx_vc11.sln, because that seems to be the one that corresponds to VS2012, right?
Anyway, it took a LONG time to load, because it had to keep scanning through thousands of files and so forth, but when it was finally finished, I did the "Rebuild All" command thrice in a row, like it says to do (which also took a while).
But I'm not sure where it even put the actual DLL file. It says that it's in C:\wxWidgets-3.1.6\build\msw....\lib\vc_lib\wxmsw31ud_xrc.lib, but where the hell is "...."? It doesn't even bother to specify the entire path! What kind of nonsense is that?! I just want the file so that I can put it into my project! Or better yet, just a .h file that takes care of everything would be great. Supposedly there's one to include called "wx/wx.h", which then includes everything else, I think, but I don't know if that one indirectly also requires a DLL.
I always have problems with DLLs, anyway, though I'll use one if I absolutely have to. You'd think it would be the easiest thing to import a DLL into a project, but for some reason, I've never been able to find any sort of tutorial that explains a specific, step-by-step way to do it which is guaranteed to work, so on the rare occasion that I actually need to use a DLL (99% of the time I can just rely on my own code and the .h files included with Visual Studio), I always end up muddling through it until it FINALLY works by sheer accident (if I'm lucky). Mostly, it just reports errors for one reason or another, that it's not properly included or compatible, or that the header files that I'm using which reference it keep showing the same errors, as though I hadn't even imported the DLL file at all! I've been programming for about 30 years, and I work on things like AI and compression and cryptographic algorithms. I don't say this to brag, but to point out that if someone as experienced as me has trouble getting a DLL to attach properly to a roject, then there's something severely wrong with the whole process, or the documentation for it! I HATE using DLLS, because it's always a HUGE chore, but I'll do it if there's absolutely no other way (though I'd appreciate step-by-step instructions, if you don't mind).
But enough about that. In any case, I have an example project in which wxWidgets is being used in conjunction with Vulkan, and though it has compilation errors (because Vulkan didn't properly install on my machine (when I try to run the sample programs it says they're missing DLLs - big surprise) and as it turns out, I don't think it's compatible with my video card, anyway (which might possibly be why it didn't install properly), so I think I'll have to resort to OpenGL instead - PLEASE tell me that's compatible with wxWidgets!), but even in that example project, it has errors where it's trying to include and use wxWidgets stuff (like "wx/wx.h"), even though that's supposed to be a complete and already working project! I can't find any DLL files or the header files in question anywhere in the project directories!
So anyway, there's got to be an easier way to get this all set up, just to the point that I can make a simple test program using wxWidgets, and compile it. I'd REALLY like to be able to get at least that much working sometime tomorrow morning, so I'd greatly appreciate any help you can give me! Thank you.
#ThisIsMe,
First of all you need to educate yourself on properly using C++.
When you acquire the C++ code it contains of 2 portion - header file and source code.
Header file is what you call a declaration you declare you classes there - class name, member variable and method.
In the source files You define what you declared and you put an actual code there.
Now with that in mind:
wxWidgets contains both header and source files. When you downloaded the installer and did the installation it just copied the "text file" (headers and sources) into the folder of you choice.
Now as you can imagine text files are not executable - you need to compile them into the binary files And that is exactly what you did. (I don't know why you did it 3 times though - I guess you got an errors after building 1st and 2nd time).
Now, you said you have a project that (either uses wxWidgets or you want to incorporate wxWidgets into - which one is it, BTW?). The answer to this question will help direct you to a proper solution.
Now, you said that you tried the Vulkan and it fails to run the demo. How did it fails? Did it produce an error? What was it? Did it even run?
Now wxWidgets does support OpenGL as can be seen by looking at the documentation and checking the different samples that comes with the library, but I'm just curious if what you are seeing from Vulkan is really an incompatibility with the Video Card.
So, we need you to answer the questions I put and so we can help you further. Just keep in mind - C++ is not for the beginner programmers and if you are struggling with understanding the difference between compilation, installation , headers and sources - it will be very hard for you.
Maybe you should start with something simpler - like wxPython and forget about C++ for now.

Xcode autocompletion does not work for C++ libraries included via CMake

I have an Objective-C based project with some C++ code. I have included library I want to use via CMake. However, Xcode autocompletion is not working properly for library's methods, classes and etc.
Despite that, project compiles and there are no errors during build after inputting some of the library classes or functions in code. Xcode can also correctly specify the error, if I miss something like required parameters for method call (It will show up build error, telling which parameter I forgot to use).
The problem is lack of autocompletion dramatically slows down the development and I need to fix it.
Considering the fact that Xcode is essentially just another UNIX make with GUI on top of it, I would advice just switching to VSCode because the C++ plugin there is designed to work with this kind of stuff.
In your case you could probably use some automatic cmake -> pbx generator if such tools even exist. Or, of course, do this manually, and configure the compilation out of an Xcode project.

Xcode support for C++

I try to use Xcode (v.7.3.1) for my C++ project (build system - make), but the experience is quite poor (and it was always like that since old versions like v4 when I started using it) - code completion doesn't work, color syntaxing works oddly (no coloring sometimes, or partially colored code), no "jump-to-definition" functionality, can't switch b/w header/source files with shortcuts. Basically, it's just a text editor where I have to use "Find" and Cmd+Shift+O all the time.
Is this intentional and Xcode will never get any proper support for C++ projects with external build system (make) or am I misconfiguring my project? How can I re-index files in the project? How can I make code completion work?
Thanks,
I believe there is a way to use Xcode with makefiles by adding an external build target, file->new->target->External Build System.
This is an older tutorial but the steps may be worth looking through: http://web.ist.utl.pt/jose.alberto.coelho/mac/MakefilesXcode.pdf
I've never had a problem with the syntax highlighting, but I remember the refactoring support being limited for C++ in some ways.
So, I ended up using this workaround: even though, I use external build system, I create Console Application project in Xcode and choose C++ language in settings. Then, I simply add my source files to the project (just drag folders from the Finder window) and then manually create project targets of type External Build System as I need. I don't use default target and don't use generated main.cpp file at all.
My files get indexed with no problems. I'm also able to debug code as I used to.
I still think Xcode developers should review indexing process for the projects with external build system...
Thanks for all the insights though!

Eclipse CDT editor doesn't recognize OpenGL extensions

I'm using Vertex Array Objects and Vertex Buffer Objects in Eclipse, but the editor doesn't appear to recognize the function declarations. The program compiles and executes without any complaint.
(Note that the errors are "Function could not be resolved.")
I've tried using both GLee and GLEW, but the results are the same. Any ideas on how to get Eclipse to recognize the functions in the editor?
In general, OpenGL function pointers like this have to be defined by macros that resolve to some function name. That plays havoc with IDEs and their attempts to figure out what is going on.
Ultimately, if your IDE can't handle it, you'll just have to find a way to live with it.
I don't know if there is anything special about OpenGl Extensions but I do know in general I often have to dig down to the root folder that contains the .h files for my library and explicitly add all the folders to my include paths. Adding the topmost parent doesn't cut it for the editor. Once I add them all I then rebuild the indices (usually to get type-ahead features working). It's strange that the editor is more picky about this than the compiler but I have seen it happen with multiple libraries.
I had this exact problem, and the only thing that fixed it was to start a brand new C++ project, make the very first include #include <GL/glew.h>, and copy in the rest of the code. If the project is set up without glew.h as the first import, it never reconfigures itself for some reason.
I tried manually messing with the project and global properties in Eclipse; nothing worked except the above.
RE: Nicol Bolas's answer, it's true that Eclipse cannot parse the macros well enough to generate all the tooltips and autocompletes, but it will recognize the functions and enforce correct arguments.
Just make sure you have the most up-to-date version of Eclipse CDT (and GLEW).
In some occasions it might work when you rebuild the index (right-click project > Index > Rebuild)

what is required to get intellisense for Gtkmm using editor Geany!

i want to get the intellisense in GTkmm application, similarly as we get in dot net under windows. However this time i am using Linux, C++, Gtkmm and Geany as my editor. Please guide how to get the intellisense. Moreover, if any kind of editor supports the property of intellisense, please mention that also.
Thanks and Regards
Owais Masood
Geany automatically indexes your open files for auto-completion, but if you want it to index some library or API, you have to create a global tags file like it describes here in the documentation. I have had mixed results getting this to work completely and correctly though.
I used to use Geany on Linux, but I have moved to QtCreator. Even though it has an emphasis on Qt, you can use it on any C or C++ project (you just have to specify your own build process or do it outside the IDE). The editor is one of the best I've used on Linux and the autocompletion works great without a whole lot of configuration. Also check out my answer here on how to set the include paths. Anything in the include paths will be indexed for autocompletion automatically.