@@ -468,9 +468,10 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro
468468
469469 const targetFromToolchains = compilerToolchains ?. target ;
470470 const targetArchFromToolchains = targetFromToolchains ? parseTargetArch ( targetFromToolchains ) : undefined ;
471+ const compilerImplicitIncludes = compilerToolchains ?. implicitIncludes ?. map ( util . platformNormalizePath ) || [ ] ;
471472
472473 const normalizedCompilerPath = util . platformNormalizePath ( compilerPath ) ;
473- let compileCommandFragments = useFragments ? ( fileGroup . compileCommandFragments || target . compileCommandFragments ) : [ ] ;
474+ const compileCommandFragments = useFragments ? ( fileGroup . compileCommandFragments || target . compileCommandFragments ) . slice ( 0 ) : [ ] ;
474475 const getAsFlags = ( fragments ?: string [ ] ) => {
475476 if ( ! fragments ) {
476477 return [ ] ;
@@ -512,12 +513,33 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro
512513 }
513514 if ( targetFromToolchains ) {
514515 if ( useFragments ) {
515- compileCommandFragments = compileCommandFragments . slice ( 0 ) ;
516516 compileCommandFragments . push ( `--target=${ targetFromToolchains } ` ) ;
517517 } else {
518518 flags . push ( `--target=${ targetFromToolchains } ` ) ;
519519 }
520520 }
521+ if ( compilerImplicitIncludes . length > 0 ) {
522+ // Extract the stem from compiler path.
523+ const compilerId = compilerPath . toLocaleLowerCase ( )
524+ . match ( / (?: ^ | [ - \/ \\ ] ) ( c l | c l a n g - c l | c l a n g \+ \+ | c l a n g | g \+ \+ | g c c ) (?: $ | [ - . ] ) / ) ?. [ 1 ] || "" ;
525+
526+ const includeFlag = {
527+ "cl" : "/external:I" ,
528+ "clang-cl" : "-imsvc" ,
529+ "clang++" : "-isystem" ,
530+ "clang" : "-isystem" ,
531+ "g++" : "-isystem" ,
532+ "gcc" : "-isystem"
533+ } [ compilerId ] || "-I" ;
534+
535+ for ( const implicitInclude of compilerImplicitIncludes ) {
536+ if ( useFragments ) {
537+ compileCommandFragments . push ( `${ includeFlag } ${ shlex . quote ( implicitInclude ) } ` ) ;
538+ } else {
539+ flags . push ( `${ includeFlag } ${ implicitInclude } ` ) ;
540+ }
541+ }
542+ }
521543
522544 this . workspaceBrowseConfiguration = {
523545 browsePath : newBrowsePath ,
0 commit comments