Skip to content

False positive : does not need to be #included with fields of structure #164

Open
@catenacyber

Description

@catenacyber

Reproducer is 3 files

  • lol.c :
#include "toto.h"
#include <stdio.h>

int main() {
	toto p;
	p.t = 3;
	printf("loli %llx\n", p.t);
	return 0;
}
  • toto.h :
#include "tata.h"

typedef struct toto {
	tata t;
} toto;
  • tata.h :
#include <stdint.h>

typedef int64_t tata;

Program compiles and behaves as expected cf :

clang lol.c
./a.out 

But running cppclean gives a false positive

cppclean toto.h 
toto.h:1: 'tata.h' does not need to be #included

Removing the include fives compilation error :

clang lol.c
In file included from lol.c:1:
./toto.h:4:2: error: unknown type name 'tata'
        tata t;
        ^
1 error generated.

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