Skip to content

included string.h but still see "implicitly declaring library function 'memcpy'" #512

@randy3k

Description

@randy3k

I am using Sublime Text LSP in macOS.

The c file

#include <string.h>

// something else

void utf8_to_utf32_callback(int cp, int m, void* data, long i) {
    uint32_t x = cp;
    memcpy((char*) data + sizeof(uint32_t) * i, &x, sizeof(uint32_t));
}

Diagnostic

      104:5   	ccls        	warning   	implicitly declaring library function 'memcpy' with type 'void *(void *, const void *, unsigned long)'
             	            	          	
             	            	          	utftools.c:104:5: note: include the header <string.h> or explicitly provide a declaration for 'memcpy'
      104:5   	ccls        	info      	include the header <string.h> or explicitly provide a declaration for 'memcpy'

When I check the ccls log file, I could see string.h is indexed.

10:01:30                  pipeline.cc:389 I store index for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h (delta: 0)

But having a closer look of the string.h, it doesn't contain the definiation of memcpy but the following derivative

#include_next <string.h>

Does it mean that ccls is not following the #include_next derivative? I cannot see other string.h file being indexed except /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h.

Please let me know if you need more information.

  • ccls installed freshly from homebrew.
  • the file could be compiled without problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions