Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malloc "a value of type "void *" cannot be used to initialize an entity of type "int *"" #10250

Closed
dennis0324 opened this issue Dec 8, 2022 · 3 comments
Assignees
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service

Comments

@dennis0324
Copy link

dennis0324 commented Dec 8, 2022

Environment

Bug Summary and Steps to Reproduce

Bug Summary:
currently i'm working on c .
Using malloc in header file but it seems vscode praser recognize header file as cpp's header file.

main.h
image

main.c
image

definition of stdlib.h
they all go to same file
image

Steps to reproduce:

  1. use malloc without casting data type in header file

Other Extensions

No response

Additional Information

No response

@dennis0324 dennis0324 changed the title malloc a value of type "void *" cannot be used to initialize an entity of type "int *" malloc "a value of type "void *" cannot be used to initialize an entity of type "int *"" Dec 8, 2022
@browntarik
Copy link
Contributor

Thank you for your issue! Could you please respond with code snippets that I can copy and use to debug this issue myself?

@dennis0324
Copy link
Author

Forgive me for being late.
When i tried in other project then malloc worked.
So I tried to find difference betwwen two project.

project that doesn't work use this settings.json

{
    "C_Cpp.default.intelliSenseMode": "gcc-x64",
    "C_Cpp.default.compilerPath": "/usr/bin/gcc",
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.default.cStandard": "c99",
    "files.associations": {
        "*.h": "c",
    },
}

when i compare two project setting.json there was a line in files.associations which is "stdlib.h":"c". So I try put stdlib.h in my not working project and i fixed my malloc problem!

but i wonder that "*.h":"c" should make all header to c compatible?

here's my fixed settings.json btw

{
    "C_Cpp.default.intelliSenseMode": "gcc-x64",
    "C_Cpp.default.compilerPath": "/usr/bin/gcc",
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.default.cStandard": "c99",
    "files.associations": {
        "*.h": "c",
        "stdlib.h":"c"
    },
}

@browntarik
Copy link
Contributor

This issue was actually fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.7 so please consider updating and let me know if you face the same issue.

@browntarik browntarik self-assigned this Dec 12, 2022
@browntarik browntarik added the bug label Dec 12, 2022
@sean-mcmanus sean-mcmanus added more info needed The issue report is not actionable in its current state Language Service fixed Check the Milestone for the release in which the fix is or will be available. and removed more info needed The issue report is not actionable in its current state labels Dec 15, 2022
@sean-mcmanus sean-mcmanus closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

3 participants