vscode-cpptools
vscode-cpptools copied to clipboard
My program compiles fine but I get the following error in vscode only "identifier "K32GetProcessMemoryInfo" is undefined"
Environment
- OS and Version: Windows 11
- VS Code Version: 1.85.2
- C/C++ Extension Version: 1.19.4
Bug Summary and Steps to Reproduce
Write the following c++ code
#include <Psapi.h>
int get_app_ram_usage() {
HANDLE current_process =
OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId());
GetProcessMemoryInfo(current_process, &memory_counters, sizeof(memory_counters));
return memory_counters.WorkingSetSize / 1024 / 1024;
}
Compile this code using LLVM clang and see it works fine.
Now vscode should report the error "identifier "K32GetProcessMemoryInfo" is undefined"
Configuration and Logs
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.suggestSnippets": false,
"C_Cpp.default.forcedInclude": [
"src/pch.hpp"
],
"C_Cpp.default.includePath": [
"lib/windows/include",
"include",
"."
],
"C_Cpp.default.compilerPath": "C:\\Program Files\\LLVM\\bin\\clang++.exe",
Other Extensions
No response
Additional context
No response
Hi @dortamiguel . Using the configuration you provided here (though, without files you did not provide), I get working IntelliSense and no squiggles using your example code (provided I also add #include <Windows.h> and the missing: PROCESS_MEMORY_COUNTERS memory_counters;).
I think we would need more information to assist you. Can you provide a self-contained example that reproduces the issue?
Also, I'd suggest always prefixing include paths that are within your workspace folder with ${workspaceFolder}/ rather than using relative paths. That would rule out these paths ever being interpreted incorrectly if evaluated while your workspace folder is not the current working directory.
I believe this is expected behavior, defined in the documentation:
If
PSAPI_VERSIONis 2 or greater, this function is defined as K32GetProcessMemoryInfo in Psapi.h and exported in Kernel32.lib and Kernel32.dll. IfPSAPI_VERSIONis 1, this function is defined as GetProcessMemoryInfo in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetProcessMemoryInfo.
See here.
Hey @Colengms, this issue might need further attention.
@dortamiguel, you can help us out by closing this issue if the problem no longer exists, or adding more information.
This issue has been closed because it needs more information and has not had recent activity.