I try to get VS-Code working for my C++ project, but I have the problem that the syntax highlighting ignores preprocessor directives like #if/#else/#endif.
I have the extensions ms-vscode.cpptools (C/C++) and ext install code-gnu-global (Intellisense) installed.
"Go To Definition" shows the #define correctly.
#define ON_TARGET false results to the same highlighting
It should look like this:
VS Code can do it with Microsoft's C/C++ extension since v 0.15
from February 2018.
Visual Studio Code can't do such things out of the box as it is "just" an editor.
If you compile your code, it will work as expected.
For evaluating such defines you need an IDE, e.g. Visual Studio, CLion or you may achieve this with additional Plugins. (e.g. C/C++ Plugin)
Related
I'm trying to setup local Windows eclipse for remote Linux development. I have encountered problem with eclipse not recognizing simple 'printf()' statement from <stdio.h>. I didn't find any helpful resources ATM to solve this problem, so wondering if you could help me with this.
Header files used from: Visual Studio Build Tools 2022, specifically I'm including this folder for stdio.h file: 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041\ucrt'
GCC C++ Compiler as: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\bin\clang.exe"
Eclipse IDE still highlights this as 'Function cannot be resolved':
I am not sure, but looks like 'printf' function is available at 'stdio.h':
Update:
Eclipse version used:
Using command line build is working as expected:
Program runs as expected:
So the questions are:
What needs to be done so eclipse would recognize 'printf'? e.g. Change MS Win Kits for another compiler header files? Or my eclipse configs are wrong?
If it is not possible for eclipse to recognize 'printf', is there an option to ignore all warnings on 'printf' (not highlight them)?
Let me know would you need anymore details from my side.
After some investigation I think 'clang' is not compatible with eclipse & it's way easier to install & use 'cygwin' for such purposes.
Some references:
https://www.eclipse.org/forums/index.php/t/1092409/
https://www.eclipse.org/forums/index.php/t/1102938/
I've installed Visual Studio Code and a number of plugins for C++ development (C/C++, CMake, Doxygen, LLDB Debugger) but I can't seem to make this work. I can't refactor, auto-complete has no clue where to look for options and syntax highlight could be much better.
Are there any configuration options I'm missing or is this just a glorified text editor?
Visual Studio Code is a Text Editor, which is available on Windows, Linux, and OSX. It has several plugins which allow you to get some cool features, you can find a lot of documentation online.
Visual Studio (or Visual C++) is an IDE (Integrated Development Environment). It is available on Windows and on OSX (for C# only for now if I remember). It provides a lot of useful Integrated tools such has syntax highlighting, auto completion, compiler and debugger, Intellisense, etc..
I really think you are mistaking those two, tell me if I'm wrong.
I saw questions similar to this for older versions of Visual Studio but not this latest version. I am following a course on Lynda.com and basically the instructor is trying to use C++ in a pure form that will look the same for students using a visual IDE on Mac. Anyway, the instructor sets up a Working project for teaching the language constructs and such. He right clicks on the project in Visual Studio and under C++ there is Pre-processor section.
I should note that he is using VS 2013 Community Edition. I have a more fully featured version of VS 2015. I don't see that option for defining pre-processor directives on a "project" basis. MS won't let me install 2 copies of VS 2015, but maybe it will let me install VS 2013.
Still, I hope my question makes enough sense as to what we are trying to accomplish, so that I can find the option in VS 2015 Enterprise.
Thanks,
Bruce
You would need to at least add a .cpp file to your Source Files folder in the the current project that you right will click. That should give you the option you are looking for in Visual Studio 2015.
Right click on your project. Select Properties. You should see the below menu where you can navigate to Configuration Properties > C/C++ > Preprocessor.
This is how I see it in my Visual Studio Enterprise 2015.
Is this what you're looking for?
I use Visual Studio 2012 to edit source code that is targeting Linux. The problem is that syntax highlighting gets it all wrong, because it thinks _WIN32, _MSC_VER, and similar macros are defined. What can I do to get rid of them?
I tried two methods:
added /u command in the property page for C++;
added /U"_WIN32" /U"_MSC_VER" and so on.
but without any effect. The problem is the same in Visual Studio 2013.
What should I do?
These are compiler-predefined macros. You can only #undef them in the code. Use a custom header file, probably.
Anyway, the requirement seems strange to me. Why do you use MSVC if you want to scan the Linux code? If the Linux code uses any GCC extensions (it often does), it can't compile under MSVC at all.
You can edit them in you're project's configuration.
Right click project->properties->C/C++->preprocessor->preprocessor definitions
I create a test project. The definitions only affected when the code be compiled.
I use Visual Studio 2010 and Intel icc compiler for C development. I use C99 but editor is still showing C99 constructs as errors (compiling is fine). How to get rid of it?
Second question, is it possible to use Eclipse (CDT) with Intel compiler on Windows?
As mentioned in the responses to your post, the problem you're seeing is with your intellisense only.
You can turn off intellisense error reporting in VS2010:
Tools > Options > Text Editor > C/C++ > Advanced. Under IntelliSense, choose "Disable Error Reporting" and set it to "True".