Skip to content

Include error because of unwanted macro which is not possible to undefine #11479

Closed

Description

Environment

  • OS and Version: Ubuntu 20.04.6 LTS
  • VS Code Version: 1.82.2
  • C/C++ Extension Version: ms-vscode.cpptools@1.17.5

Bug Summary and Steps to Reproduce

I am writing an extension to support tool-chain which is cross compiling for another os. I.e. its not windows, linux or mac.
The problem is there is always error which is coming from system includes because its trips on __linux__ which expand
code segment to to something which cannot be found. My compiler does not define it, but unfortunately default intelliSenseMode mode does and there is no way to undefine it via configuration

Proposed solutions (one of):

  • provide intelliSenseMode NOT bound to host, i.e. other-gcc-x86 (etc) which does not define __linux__, max or windows macros
  • provide intelliSenseMode common which does not define ANY additional defines (since it already exists maybe just allowing this to be used as value would solve this)
  • provide "undefines" along "defines" in the c_cpp_properties
  • allow "defines" to undefine vars some-how, i.e. !__linux__

Bad workarounds:

  • Set intelliSenseMode to other value, i.e. windows on linux - that did not work: For C source files, IntelliSenseMode was changed from "windows-gcc-x64" to "linux-gcc-x64" based on compiler args and querying compilerPath: "/host/linux/x86_64/usr/bin/q++"
  • Create undef.h, write #undef __linux__ in there and use forcedInclude - that is super ugly because I would either have to generate this file in every project or in some common area with limited way to refer to this file c_cpp_properties without full path

Configuration and Logs

Can reproduce with this fake program, I want a way to make it not error out (running on linux host), since my compiler does not define this macro

#ifdef __linux__
#include "fake.h"
#endif

void main(){}

Other Extensions

No response

Additional context

No response

Activity

  1. michelleangela commented on Sep 29, 2023

    @michelleangela
    Contributor

    Alena Laskavaia (@elaskavaia)
    Thank you for reporting this issue. We determined it is a duplicate of #4653 (please up-vote to increase its priority), which is supposed to address various platform/architecture/compiler features that impact defines or headers or IntelliSense configs based on IntelliSense mode.

  2. locked and limited conversation to collaborators on Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions