vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

cpptools can't recognize far/near keyword

Open Lennon925 opened this issue 7 years ago • 15 comments

捕获

error shows: "expected a ';' "

Lennon925 avatar Sep 29 '19 01:09 Lennon925

Our parser has near/far support disabled (same as the VS default). How exactly are you getting your compiler to support that? i.e. what compiler/flags? I see it used for 16-bit compilation with older Microsoft compilers.

sean-mcmanus avatar Sep 30 '19 18:09 sean-mcmanus

I am using VS Code to edit the code of an old project on 80186 based µC and have the same errors with far/near pointers. It is no wonder that I can't complie my project with modern compilers but I really like the features of VS Code such as IntelliSense

qk-li avatar Dec 16 '19 15:12 qk-li

A workaround would be to add "near=" and "far=" to the "defines" array in c_cpp_properties.json

bobbrow avatar Jul 09 '20 21:07 bobbrow

This feature request is being closed due to insufficient upvotes. When enough upvotes are received, this issue will be eligible for our backlog.

github-actions[bot] avatar Oct 17 '20 11:10 github-actions[bot]

I've also just run into this while working with a codebase targeting the venerable NEC V30 chip, using the Watcom compiler..

hmaon avatar Apr 07 '21 19:04 hmaon

This feature request has received enough votes to be added to our backlog.

github-actions[bot] avatar Apr 08 '21 12:04 github-actions[bot]

We should check if this is something easy for the IntelliSense parser to support.

Colengms avatar Apr 13 '21 23:04 Colengms

@bobbrow Your suggestion to do this

    "C_Cpp.default.defines": [
        "near=",
        "far="
    ]

does not solve the issue for me, unfortunately.

Does anyone have another suggestions? I am still getting the expected a ';' or expected a ')' error.

This probably also causes types not being resolved in other places.

Phyioa avatar Jul 08 '21 09:07 Phyioa

@Phyioa Do you have a c_cpp_properties.json or compileCommands or configurationProvider set? Those could be overwriting the C_Cpp.default.defines. You could tell if the define is being recognized by hovering it.

image

sean-mcmanus avatar Jul 08 '21 19:07 sean-mcmanus

@sean-mcmanus Yes, it seems like I do have a c_cpp_properties.json, which I didn't know of. It has the following contents right now.

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${default}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.14393.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

I have neither compileCommands nor configurationProvider set.

Hovering some of the fars I found in the code does not indicate that the defines are recognized.

Any tips on how to proceed? Thanks for your help so far! <3

Phyioa avatar Jul 09 '21 06:07 Phyioa

@Phyioa Add "${default}" to your list of defines in c_cpp_properties.json (see https://code.visualstudio.com/docs/cpp/customize-default-settings-cpp for more info).

sean-mcmanus avatar Jul 09 '21 06:07 sean-mcmanus

@sean-mcmanus Oh my god! You are a life savior! Thank you so much. <3 Works like a charm now! :)

Phyioa avatar Jul 09 '21 08:07 Phyioa

is it OK to add the defines to c_cpp_properties.json directly, like this?

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "near=",
                "far="
            ],
            "windowsSdkVersion": "10.0.18362.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

It seems to work fwiw.

hmaon avatar Aug 20 '21 17:08 hmaon

This could be addressed after #6931 is completed

bobbrow avatar Jan 03 '25 21:01 bobbrow

we may be waiting for another years

heartacker avatar Jan 03 '25 22:01 heartacker