Search code examples
androidvisual-studio-codex86-64cross-compilingarm64

How to navigate to the structure definition for the target architecture when cross-compiling on Ubuntu with VS Code?


I am cross-compiling Android arm64 binary files on Ubuntu. I have defined a struct called user_regs_struct old_regs. When I press ctrl + click in VS Code, it takes me to the structure definition inside the #elif defined(x86_64) section in android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/sys/user.h file. However, I want to navigate to the structure definition under the #elif defined(aarch64) section. I'm not sure how to set this up in VS Code.

Can anyone guide me on how to configure VS Code to navigate to the structure definition for the ARM64 architecture instead of the x86_64 architecture?

Thank you!

I try #define aarch64 1 in my code.


Solution

  • c_cpp_properties.json. give the correct value for compilerPath and intelliSenseMode

    {
        "configurations": [
            {
                "name": "Linux",
                "includePath": [
                    "${workspaceFolder}/**",
                    "~/android-ndk-r25c",
                    "~/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/**"
                ],
                "defines": [],
                "compilerPath": "~/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang ",
                "cStandard": "c17",
                "cppStandard": "gnu++17",
                "intelliSenseMode": "linux-clang-arm64"
            }
        ],
        "version": 4
    }