VSCode turn of _WIN32 define - visual-studio-code

I have an embedded project in VisualStudio code which works perfectly fine for the most part. My problem is that somehow _WIN32 is always defined, which leads to wrong includes in some header files.
I guess the problem is an Intellisense issue because the project compiles without any errors (I use the IAR compiler). It's just the error squiggles from Intellisense which display the error.
(For example in one header file it trys to open <windows.h> because of the _WIN32 define, which obviously will fail in an embedded project with an embedded compiler, so Intellisense reports that it can't open the header file)
Now, what i tried so far:
Changing the Intellisense mode but even if I switch it to gcc or clang for ARM, _WIN32 stays defined
Trying to remove the _WIN32 define from code, but it seems that VSCode defines it internally (if that makes any sense ?).
I looked at this thread where they try to answer the question where _WIN32 is defined. But that didn't help me either.
Does anyone have an idea why _WIN32 is defined or where it is defined ? How can i tell VisualStudio code / Intellisense to not define _WIN32 ?
Thanks in advance.

Most likely, the problem is VSCode is using the wrong C++ compiler to gather the predefined macros; that is the likely source of the _WIN32 definition. Use the command Palette (Ctrl+Shift+P) to run "C/C++: Edit Configurations (UI)", then set "Compiler path" to point at your compiler executable (IAR in this case). That should solve the problem because VSCode will then query that compiler to determine the predefined macros.
To confirm the fix, in Command Palette, run "C/C++: Log Diagnostics". The output will show you which compiler VSCode found and what it detected as its built-in include path and preprocessor defines. You should see that _WIN32 is no longer among them. (You might want to run this before changing anything to see the difference.)
Also, you mentioned changing the Intellisense mode. I believe the effect of that switch is related to C++ language dialect issues, especially support for certain bugs in certain compilers. It is unrelated to whether any preprocessor symbols are defined.
(Some of the text in this answer is copied from another answer of mine that more broadly discusses configuring VSCode to emulate a given compiler.)

Related

VSCode SCSS extension with better error checking

I recently started writing SCSS in VSCode. VSCode itself along with vscode-scss extension provides relatively good support for SCSS, but an important feature seems missing - error checking.
Though VSCode and vscode-scss can offer suggestions through Intellisense based on scanning, no errors will be prompted if I misspelled a variable, or used a mixin that hadn't been imported yet. Also, no auto refactoring takes place after renaming an SCSS file that has been used by other sources.
Is there any VSCode extension that provides such validations? Or maybe they can be turned on through some options in extension settings?
Note: I do have noticed the scss.showErrors option of vscode-scss, but no errors get prompted in scenarios mentioned above after turning this option on.

Disable competing language servers / code highlighters

I want to add a language server to handle completion / highlighting / etc. for a file.
As a basis for testing stuff I am using an example from Microsoft (https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-sample) and changed it to be active for any File. This language server highlights any word in all capital letters.
When opening a C++ File, I get the highlighting / completion of my language server and the default one for C++ (See image).
I would like to detect if some other extension / build in highlighter is active for a file and deactivate it for this workspace or the current file if it is impossible for the current workspace)
Is there a way to do this in a generic way where I do not have to know which extensions are highlighting code?
If no, is there a way to do this, if I know a set of extensions I want to deactivate?
I finally had enough time to try around a bit more and found that providing your own language for the same extension is enough.
In package.json I added an element in contributes.languages with extensions containing .cpp (since I am using cpp files for testing).
I also copied over some implementation code from an example.
This suppressed the default highlighter and code completion for cpp files. Since i am only implementing a semantic token provider, I can see the default highlighting before my provider takes over. (I think this could be solved by adding a syntax highlighter, but this is already sufficient fo my preliminary testing)
I am not sure, how stable all of this would be as a plugin (I only tested in Extension Development Host mode)
Here an image of the results:

VS Code, Syntax highlighting Powershell

Ive been scratching my head with this one. Previously VS Code highlighted Powershell scripts and modules just fine with highlighting functions in yellow and variables $var in light blue. Both as part of a string and "stand-alone". However, suddenly it doesn't highlight functions or variables anymore? I've tried to uninstall and reinstall the powershell extension from Microsoft, as well as disable and re-enable the built in language support for powershell.
I've not been able to find any support regarding this issue and hope that I might be able to find it here.
Have you tried this?
File Association.
Basically:
The easiest way I've found for a global association is simply to Ctrl+k m (or Ctrl+Shift+P and type "change language mode") with a file of the type you're associating open.
In the first selections will be the option "Configure File Association for 'x' " (whatever file type - see image attached). Selecting this gives you the option to choose the language and will then make the filetype association permanent.
if you start your code block with a ```PowerShell it will highlight the syntax properly.
I've noticed that you may also need to end your code block with a ``` in VSCode specifically.

How to make VSCode's python debugger skip stepping into some modules when debugging

In vscode's python (ms-python) extension, is there a way to make the debugger (debugpy) not to step-into functions defined in specific modules. I have found justMyCode but it will skip entering into external modules only (like members of stdlib) while I need to skip my own modules sometimes.
I saw some debug adaptors for some other languages implement skipFiles property. Is there anything similar for python?
Going thru debugpy code I found this undocumented feature which works like a charm: in launch.json's debug configuration add
"rules" : [{"module":"*xxx*", "include":false}]. Make sure the xxx is the full module name like a.b.module
There are more working options. They can be seen here
A word of warning. This feature is undocumented (at least I did not find it anywhere) so use with caution as it might disappear one day. At the other hand, this feature is properly tested as part of the code uni-testing (as you can see from the link)

No definition found in vscode for system libraries

I'm new to vscode so I'm not sure if this is possible, but in visual studio you can cmd+click into a method and see the definition. In VS code, when I try to see the definition, it says no definition found. For example
using System.Collections;
when I try to see the definition for "Collections", it says "no definition found". How can that be? This is a system library. Does VS code even support this feature of jumping into a library?
I think I misunderstood what VSCode is. I expected it to be an IDE but it's really just a glorified text editor. I don't think what I'm asking is possible.