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

[ERROR] C4996 for strdup in texture-font.c : Nicolar Rougier #284

Open
yeokaiwei opened this issue Jul 18, 2024 · 1 comment
Open

[ERROR] C4996 for strdup in texture-font.c : Nicolar Rougier #284

yeokaiwei opened this issue Jul 18, 2024 · 1 comment

Comments

@yeokaiwei
Copy link

Hi Nicolas
Visual Studio 2022 will highlight the following error with texture-font.c.

Should this be changed?

Thank you.

Error C4996 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup.

// --------------------------------------------- texture_font_new_from_file ---
texture_font_t *
texture_font_new_from_file(texture_atlas_t *atlas, const float pt_size,
                           const char *filename)
{
    texture_font_t *self;

    assert(filename);

    self = calloc(1, sizeof(*self));
    if (!self) {
        freetype_gl_error( Out_Of_Memory );
        return NULL;
    }

    self->atlas = atlas;
    self->size  = pt_size;

    self->location = TEXTURE_FONT_FILE;
    self->filename = strdup(filename);         <<----- HERE

    self->mode = mode_default;
    
    if (texture_font_init(self)) {
        texture_font_delete(self);
        return NULL;
    }

    return self;
}

Screenshot 2024-07-18 213746

@rougier
Copy link
Owner

rougier commented Aug 28, 2024

Not quite sure actually. Is is specific to VSCode ? Is there a macro to test for deprecation ? Else, I'm afraid this could fail on other platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants