VSCode- exclude specific folder/file from IntelliSense parsing - visual-studio-code

I have an issue with C/C++ intelliSense parsing. When the function declaration described in one file and the same name is used for typedef in another file.
Explanation:
Image we have next structure of folders and files:
file dir1/f1.h contains:
typedef int func1;
file dir2/f1.h contains:
void func1(void);
file dir2/f1.c contains:
#include "f1.h"
void func1(void) {
// do something
}
file main.c contains:
#include "f1.h"
int main(void) {
func1();
}
When I use command go to definition, the IntelliSense goes to the dir1/f1.h file because the last open file was dir1/f1.h. If the last opened file was dir2/f1.h the IntelliSense will jump to dir2/f1.h or dir2/f1.c.
I am wondering how to exclude dir1 or dir1/f1.h from IntelliSense parsing but not from workspace and searching results? So I need next:
IntelliSense ignore/do not parse dir1 or dir1/f1.h
dir1 and dir1/f1.h present in workspace view
searcher do not ignore dir1/f1.h

Related

How to put the .h file in modulemap file properly?

I have the native static lib that has a few .h files as API, the dir structure looks like this
3rdParties -
- MyAPIHeader.h
- my.modulemap
my modulemap file looks like this
module MyAPIHeader {
header "MyAPIHeader.h"
export *
}
and everything works well, up until I need to add another API file to my modulemap structure that does not reside in the same dir.
anotherProjectDir -
- AnotherAPIHeader.h
3rdParties -
- MyAPIHeader.h
- my.modulemap
and my modulemap file looks like this
module MyAPIHeader {
header "MyAPIHeader.h"
export *
}
module AnotherAPIHeader {
header "AnotherAPIHeader.h"
export *
}
and then when I try to use AnotherAPIHeader functions, I got such an error in the modulemap file
Header 'AnotherAPIHeader.h' not found
I tried to set the path to the .h file in the module map as relative (not works) then I tried to set the path to the header file in the target (not works).
To sum up - when the .h file that is included in the module map resides in the same dir as a module map it works, when .h file resides in the other dir there is no way to set relative dir to that .h file.
What am I missing?
I think what you are looking for is an umbrella header. They basically allow you to specify what headers you want in a module. Here is a site explaining them.

how package text files into vscode extension

my extension is using handlebars to apply substitution variables to a text template. Where can I store the template text in the extension?
I am currently storing the templates as strings in the extension.ts file. Would rather use a folder that stores the template files and include that folder in the vsce package.
To store, package and access files, you can do the following:
create a sub-folder in your extension root (same level as package.json), let's give it a name resources.
Place a file.txt in that folder
The file will get packaged as long as you do not list it in .vscodeignore (as mentioned by Gama11)
Access it using the context.asAbsolutePath(...) API
Example:
import * as path from 'path';
import * as fs from 'fs';
export function activate(context: ExtensionContext) {
let fullFilePath = context.asAbsolutePath(path.join('templates', 'file.txt'));
fs.readFile(fullFilePath, (err, data) => { ... });
}

WinDbg TTD: No trace files were identified from this record session

Trying to record execution of Hello World with WinDbg from store.
WinDbg settings:
Executable path: C:\Users\...\Documents\Visual Studio 2017\Projects\TestApplication\Debug\TestApplication.exe
Output directory: c:\Users\...\Documents\
Code:
#include "stdafx.h"
#include "iostream"
using namespace std;
int main()
{
std::cout << "Hello World!\n";
return 0;
}
Error:
TTD: No trace files were identified from this record session
The debugging session could not be started: Path cannot be null.
Parameter name: path
Why it's does not work? What I am missing?
Occasionally TTD recording has trouble creating TTD files to paths with spaces. Recommend entering or pointing Output Directory to save TTD files to a path with no spaces.

Why can't #Include work?

Why does this not work?
#Include D:\Data\Download\Scripts Latex2Unicode.ahk
It says
Include file "D:\Data\Download\Scripts Latex2Unicode.ahk" cannot be opened. The program will exit.
It isn't different from the help page.
Probably you mean:
#Include D:\Data\Download\Scripts\Latex2Unicode.ahk
presuming the directory is "Scripts" and the file name "Latex2Unicode.ahk"
Let us know . . .
EDIT: Note, in the Help example:
#Include C:\My Documents\Scripts\Utility Subroutines.ahk
the file name is "Utility Subroutines.ahk" in the "Scripts" directory -- the directory is not "Utilities" and the file name is not "Subroutines.ahk"

How can I call functions in a different C source file from a Perl XS module?

I am building an XS extension with Perl. I have two files:
A C header file (.h)
A C source file (.c)
Currently what i did is to put all the C file code before the Model= on the XS file and wrap the functions I want after the Model=.
The compliation works with no problem and i am able to call the specific functions from perl.
But I want to separate the .xs file from the C file.
I want the .xs file to contain only the wrap functions, and those functions will call the functions on the .c file, but when I do that and run the dmake command i get error code 129 undefined reference to 'parse.c' file.
I tried to include the .c file using C and OBJECT properties for WriteMakerFile and still get an error any idea how to split the xs file to 2 one c file and the other xs which wrap the c function which are part of the .c file using ExtUtils::MakeMaker.
Examples would be appreciated.
This is actually rather straightforward:
hello.h
#ifndef H_HELLO
const char *hello(void);
#define H_HELLO
#endif
hello.c
const char *
hello(void) {
return "Hello";
}
Example.xs
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include "hello.h"
MODULE = My::Example PACKAGE = My::Example PREFIX = MY_
PROTOTYPES: DISABLE
const char *
MY_hello()
CODE:
RETVAL = hello();
OUTPUT:
RETVAL
t/My-Example.t
use strict;
use warnings;
use Test::More;
BEGIN { use_ok('My::Example') };
is(My::Example::hello(), 'Hello', 'hello returns "Hello"');
done_testing;
[~/tmp/My-Example]$ prove -vb t/My-Example.t
t/My-Example.t ..
ok 1 - use My::Example;
ok 2 - hello returns "Hello"
1..2
ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs
( 0.04 usr 0.01 sys + 0.03 cusr 0.00 csys = 0.08 CPU)
Result: PASS
The Makefile.PL was generated by h2xs. The only thing I changed was to uncomment the following line:
# Un-comment this if you add C files to link with later:
OBJECT => '$(O_FILES)', # link all the C files too
I think this is a rather old post but I admit that the key is the proper directory structure and file placement. You must put the other .c source files into the same directory where your xs file is. And put your xs file into the directory where your Makefile.PL is. (I assume you do not set MULTIXS as 1 in your Makefile.PL). The reason for this placement restriction is that CCCMD compile command in generated makefile does not have -o option, so all output object files will be placed into the directory where your generated Makefile is.
On CPAN I have found/checked some modules having source files in different sub dirs than xs file but they overrides ExtUtils::MakeMaker const_cccmd sub and append -o option on the fly during Makefile generation.