none
How to get Visual Studio 2015 IntelliSense to read and parse C/C++ header errors correctly for Makefile projects?

    Question

  • I have a Makefile project with its own unique toolchain that it uses to compile C and C++ codes to something a device can read. I would like to use Visual Studio and IntelliSense to help me out.

    I did all the necessary setups it required for IntelliSense to read/parse the C include headers and C++ include headers, but I noticed the toolchain provides their own GNU C and GNU C++ standard headers, located in weird file paths. For example, they would put GNU standard C++ headers and associated header files inside "/path/to/toolchain/include/c++/5.3.0/" I don't know exactly why it needs to be placed as such, but I figured it should be the same as giving the Include Paths the reference to the root folder to parse header files with (using "/include/c++/5.3.0/" as the actual root include folder).

    I was wrong.

    I now have 1,245 IntelliSense errors, mostly because the GNU standard C and standard C++ headers use a different C syntax (My presumption, and may be incorrect.) that the toolchain itself allows, but not for IntelliSense. Things like std::string has the error, "namespace std has no member string" when putting "#include <string>" at the top of the main.cpp.

    I really am lost at this point, because I thought IntelliSense will be able to pick up GNU standard C and standard C++ header function prototypes, typical namespace declarations, and such. Or maybe it is because my VC++ Directories in the Project Property Pages are not set correctly.

    For references, here's the File Explorer directory when opening up the include folders listed above:

    For this image shown below, I have no idea if I should put "/include/c++/5.3.0/" in or just use "/include/":

    They all use MinGW GCC to compile the code, so I don't know if this is relevant to IntelliSense throwing errors of all sorts around.

    Please let me know if I'm missing something else, or you need more updated info. 

    In short, how can I fix the 1,245 IntelliSense errors when working with Makefile projects? Or what fixes should I need to do to get rid of these errors?

    Thanks.


    Sunday, June 19, 2016 6:53 PM

Answers

  • Try adjusting and adding the following two directories to Include Directories:

      C:\....\devkitARM\arm-none-eabi\include\c++\5.3.0
      C:\....\devkitARM\arm-none-eabi\include\c++\5.3.0\arm-none-eabi

    This should at least solve the problem of ‘namespace “std” has no member “string”’.

    In order to fix other Intellisense messages, try opening the header files shown in Error List window, marked as Intellisense issues. Then investigate the cause and find some workarounds. For example, the next lines can be added to the beginning of main.cpp:

    #if __INTELLISENSE__

    typedef unsigned int __SIZE_TYPE__;

    typedef unsigned long __PTRDIFF_TYPE__;

    #define __attribute__(q)

    #define __builtin_strcmp(a,b) 0

    #define __builtin_strlen(a) 0

    #define __builtin_memcpy(a,b) 0

    #define __builtin_va_list void*

    #define __builtin_va_start(a,b)

    #endif

    This will solve a series of incompatibilities and will not affect the compilation.




    • Edited by Viorel_MVP Wednesday, July 20, 2016 6:19 AM
    • Marked as answer by tom_mai78101 Thursday, July 21, 2016 5:09 PM
    Wednesday, July 20, 2016 6:10 AM

All replies

  • Hi tom_mai78101,

    Please try with the steps in following article which introduce how to enable IntelliSense for Makefile Projects. Please try set Include Search Path property as the path of the toolchain.

    https://msdn.microsoft.com/en-us/library/ms173379.aspx

    And in order to confirm whether it is related to the toolchain itself, please try change another toolchain using the same steps. In addition, please tell us what's toolchain you are use and the detailed steps that you operated. I will create a sample project and try reproduce your problem in my side.

    In addition, there has any other communities has the problem about using some toolchain in there project. Please refer to the answer in following thread. Hope that can help you.

    http://stackoverflow.com/questions/19820718/how-to-make-visual-studio-use-the-native-amd64-toolchain

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 21, 2016 10:12 AM
    Moderator
  • I'll do my best to describe what I did. I really wanted to get this IntelliSense parsing problem solved.

    I have done all the steps in the first link so far. That nailed down all the errors from 1,246 IntelliSense errors to 39 IntelliSense errors.

    After doing things from the first link, I did what you suggested by creating a separate Makefile project using a different toolchain. I have the following toolchains installed, since I have a 64-bit Windows 10 operating system:

    • MinGW-64
    • Cygwin64

    And the new default toolchain I used is a default, vanilla Cygwin64 toolchain.

    The steps I used:

    1. I created a brand new Makefile project.
    2. In the Makefile Project wizard, I followed the instructions, and filled out all the Build, Clean, and Rebuild commands with the default NMake targets ("all", "clean", and "clean all").
    3. I clicked Finish to complete the setup process.
    4. In the Solution Explorer, I went to the Project Properties page.
    5. I clicked on the VC++ Directories, and added the Cygwin64 include folder file path ("C:\cygwin64\usr\include") to the Includes Directories. I only added the file path in, without changing nor removing the default filepaths it gave.
    6. I then clicked on the NMake, and added the same file path ("C:\cygwin64\usr\include") to the Includes Search Path.
    7. Then I clicked Apply and OK to complete the process.

    The results show the default Cygwin64 toolchain in a brand new Makefile project will give at least 2 IntelliSense errors with an empty test.cpp file, particularly pointing out GCC extension macro: __extension__, and other macros not defined in a default MSVC IntelliSense.

    Both Makefile projects contains IntelliSense errors that it cannot parse. My guess is the IntelliSense parser, which is separate from MSVC compiling parser, cannot parse the header files correctly, particularly with GCC extensions that are used universally across all GCC toolchains I have come across with.

    The solution to the AMD64 Native toolchain is a very specific problem related to AMD64 native processors and is not related to the toolchains that I am using. For me, the toolchains I am using is for MinGW and Cygwin64 in general. I believed the other communities does not particularly know about fixing the issues associated with MinGW and Cygwin64.

    I have written a UserVoice feature request, aimed to improve IntelliSense parsing support for MinGW and Cygwin toolchains.




    Thursday, June 23, 2016 11:45 PM
  • Hi tom_mai78101,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thanks for your understanding!

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 24, 2016 2:27 AM
    Moderator
  • Hello,

    How is the process coming along? 

    Wednesday, July 20, 2016 12:58 AM
  • Try adjusting and adding the following two directories to Include Directories:

      C:\....\devkitARM\arm-none-eabi\include\c++\5.3.0
      C:\....\devkitARM\arm-none-eabi\include\c++\5.3.0\arm-none-eabi

    This should at least solve the problem of ‘namespace “std” has no member “string”’.

    In order to fix other Intellisense messages, try opening the header files shown in Error List window, marked as Intellisense issues. Then investigate the cause and find some workarounds. For example, the next lines can be added to the beginning of main.cpp:

    #if __INTELLISENSE__

    typedef unsigned int __SIZE_TYPE__;

    typedef unsigned long __PTRDIFF_TYPE__;

    #define __attribute__(q)

    #define __builtin_strcmp(a,b) 0

    #define __builtin_strlen(a) 0

    #define __builtin_memcpy(a,b) 0

    #define __builtin_va_list void*

    #define __builtin_va_start(a,b)

    #endif

    This will solve a series of incompatibilities and will not affect the compilation.




    • Edited by Viorel_MVP Wednesday, July 20, 2016 6:19 AM
    • Marked as answer by tom_mai78101 Thursday, July 21, 2016 5:09 PM
    Wednesday, July 20, 2016 6:10 AM
  • Try adjusting and adding the following two directories to Include Directories:

      C:\....\devkitARM\arm-none-eabi\include\c++\5.3.0
      C:\....\devkitARM\arm-none-eabi\include\c++\5.3.0\arm-none-eabi

    This should at least solve the problem of ‘namespace “std” has no member “string”’.

    In order to fix other Intellisense messages, try opening the header files shown in Error List window, marked as Intellisense issues. Then investigate the cause and find some workarounds. For example, the next lines can be added to the beginning of main.cpp:

    #if __INTELLISENSE__

    typedef unsigned int __SIZE_TYPE__;

    typedef unsigned long __PTRDIFF_TYPE__;

    #define __attribute__(q)

    #define __builtin_strcmp(a,b) 0

    #define __builtin_strlen(a) 0

    #define __builtin_memcpy(a,b) 0

    #define __builtin_va_list void*

    #define __builtin_va_start(a,b)

    #endif

    This will solve a series of incompatibilities and will not affect the compilation.




    Hello Viorel,

    Your solution gave me a nice direction to work towards. Other than your code, I need to add the following beneath it:

    #if defined(_MSC_VER)
    #include <BaseTsd.h>
    typedef SSIZE_T ssize_t;
    #endif

    And all of the Intellisense errors went away.

    Program builds successfully!

    Thanks again for your help! 

    Thursday, July 21, 2016 5:09 PM