Forum: PC-Programmierung PC-Lint und <string.h> Fehlermeldungen


von Matthias (Gast)


Angehängte Dateien:

Lesenswert?

Hallo zusammen!

Ich benötige eure Hilfe bei der Nutzung von PC-Lint. Ich nutze WinAVR 
und möchte folgenden Quellcode durch PC-Lint prüfen lassen:
1
#include <stdint.h>
2
#include <string.h>
3
4
typedef struct
5
{
6
    uint8_t Var1;
7
}T_MY_DATATYPE;
8
9
void TestMain (void)
10
{
11
  T_MY_DATATYPE Test;
12
  memset (&Test, 0x00, sizeof(Test));
13
}

Daraufhin bekomme ich folgende Fehlermeldungen von PC-Lint ausgegeben:
1
**** Build of configuration PC-Lint for project 01_Rfm12Test ****
2
3
C:\Programme\Lint\LINT-NT.EXE +v -u E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Project\Specific\Rfm12Test.lnt E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c 
4
5
PC-lint for C/C++ (NT) Ver. 8.00g, Copyright Gimpel Software 1985-2002
6
--- Module:   E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c
7
--- Module:   E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c
8
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:7: Error: Error 129 declaration expected, identifier 'T_MY_DATATYPE' ignored
9
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:7: Error: Error 19 Useless Declaration
10
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:11: Error: Error 40 Undeclared identifier 'T_MY_DATATYPE'
11
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:11: Warning: Warning 522 Expected void type, assignment, increment or decrement
12
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:11: Error: Error 10 Expecting ';'
13
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:12: Info: Info 718 Symbol 'memset' undeclared, assumed to return int
14
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:12: Info: Info 746 call to function 'memset()' not made in the presence of a prototype
15
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:12: Error: Error 40 Undeclared identifier 'Test'
16
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:12: Error: Error 40 Undeclared identifier 'Test'
17
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:14: Info: Info 766 Header file 'C:\Program Files\WinAVR\avr\include\stdint.h' not used in module 'E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c'
18
19
--- Global Wrap-up
20
21
 Note: Note 900 Successful completion, 10 messages produced

Die Präprozessor-Ausgabe von PC-Lint sieht folgendermaßen aus:
1
**** Build of configuration PC-Lint for project 01_Rfm12Test ****
2
3
C:\Programme\Lint\LINT-NT.EXE +v -u -p E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Project\Specific\Rfm12Test.lnt E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c 
4
PC-lint for C/C++ (NT) Ver. 8.00g, Copyright Gimpel Software 1985-2002
5
6
--- Global Wrap-up
7
8
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:14: Note: Note 900 Successful completion, 0 messages produced
9
10
/* --- Module:   E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c */
11
/*lint -e725*/
12
/*lint ++flb*/
13
14
typedef signed char int8_t;
15
typedef unsigned char uint8_t;
16
typedef signed int int16_t;
17
typedef unsigned int uint16_t;
18
typedef signed long int int32_t;
19
typedef unsigned long int uint32_t;
20
typedef signed long long int int64_t;
21
typedef unsigned long long int uint64_t;
22
typedef int16_t intptr_t;
23
typedef uint16_t uintptr_t;
24
typedef int8_t int_least8_t;
25
typedef uint8_t uint_least8_t;
26
typedef int16_t int_least16_t;
27
typedef uint16_t uint_least16_t;
28
typedef int32_t int_least32_t;
29
typedef uint32_t uint_least32_t;
30
typedef int64_t int_least64_t;
31
typedef uint64_t uint_least64_t;
32
typedef int8_t int_fast8_t;
33
typedef uint8_t uint_fast8_t;
34
typedef int16_t int_fast16_t;
35
typedef uint16_t uint_fast16_t;
36
typedef int32_t int_fast32_t;
37
typedef uint32_t uint_fast32_t;
38
typedef int64_t int_fast64_t;
39
typedef uint64_t uint_fast64_t;
40
typedef int64_t intmax_t;
41
typedef uint64_t uintmax_t;/*lint --flb*/
42
/*lint ++flb*/
43
/*lint ++flb*/
44
45
typedef long unsigned int size_t;/*lint --flb*/
46
47
extern int ffs (int __val) __attribute__((__const__));
48
extern int ffsl (long __val) __attribute__((__const__));
49
extern int ffsll (long long __val) __attribute__((__const__));
50
extern void *memccpy(void *, const void *, int, size_t);
51
extern void *memchr(const void *, int, size_t) __attribute__((__pure__));
52
extern int memcmp(const void *, const void *, size_t) __attribute__((__pure__));
53
extern void *memcpy(void *, const void *, size_t);
54
extern void *memmem(const void *, size_t, const void *, size_t) __attribute__((__pure__));
55
extern void *memmove(void *, const void *, size_t);
56
extern void *memrchr(const void *, int, size_t) __attribute__((__pure__));
57
extern void *memset(void *, int, size_t);
58
extern char *strcat(char *, const char *);
59
extern char *strchr(const char *, int) __attribute__((__pure__));
60
extern char *strchrnul(const char *, int) __attribute__((__pure__));
61
extern int strcmp(const char *, const char *) __attribute__((__pure__));
62
extern char *strcpy(char *, const char *);
63
extern int strcasecmp(const char *, const char *) __attribute__((__pure__));
64
extern char *strcasestr(const char *, const char *) __attribute__((__pure__));
65
extern size_t strcspn(const char *__s, const char *__reject) __attribute__((__pure__));
66
extern char *strdup(const char *s1);
67
extern size_t strlcat(char *, const char *, size_t);
68
extern size_t strlcpy(char *, const char *, size_t);
69
extern size_t strlen(const char *) __attribute__((__pure__));
70
extern char *strlwr(char *);
71
extern char *strncat(char *, const char *, size_t);
72
extern int strncmp(const char *, const char *, size_t) __attribute__((__pure__));
73
extern char *strncpy(char *, const char *, size_t);
74
extern int strncasecmp(const char *, const char *, size_t) __attribute__((__pure__));
75
extern size_t strnlen(const char *, size_t) __attribute__((__pure__));
76
extern char *strpbrk(const char *__s, const char *__accept) __attribute__((__pure__));
77
extern char *strrchr(const char *, int) __attribute__((__pure__));
78
extern char *strrev(char *);
79
extern char *strsep(char **, const char *);
80
extern size_t strspn(const char *__s, const char *__accept) __attribute__((__pure__));
81
extern char *strstr(const char *, const char *) __attribute__((__pure__));
82
extern char *strtok(char *, const char *);
83
extern char *strtok_r(char *, const char *, char **);
84
extern char *strupr(char *);/*lint --flb*/
85
86
typedef struct
87
{
88
uint8_t Var1;
89
}T_MY_DATATYPE;
90
void TestMain (void)
91
{
92
T_MY_DATATYPE Test;
93
memset (&Test, 0x00, sizeof(Test));
94
}

Die Fehlermeldungen scheinen von den 'extern' Anweisungen in <string.h> 
auszugehen. In der PC-Lint Dokumentation habe ich kein Parameter 
gefunden, damit PC-Lint diese korrekt verarbeitet.

Meine PC-Lint-Konfigurationsdatei habe ich angehängt!

Ich hoffe ihr könnt mir Helfen...

Viele Grüße
Matthias

: Verschoben durch Admin
von Karl H. (kbuchegg)


Lesenswert?

> Die Fehlermeldungen scheinen von den 'extern' Anweisungen in
> <string.h> auszugehen.

Das glaube ich eigentlich nicht.
Die erste Meldung vom lint bezieht sich auf den T_MY_DATATYPE. Das ist 
schon etwas spät, wenn tatsächlich ein Funktionsprototyp der Übeltäter 
sein sollte. In dem Fall würde ich die erste Diagnostic beim typedef 
erwarten. typedef ist in keinem Kontext eines Funktionsprotoypen ein 
gültiges Schlüsselwort.

Mach aus der anonymen struct mal eine benannte
1
typedef struct irgendwas
2
{
3
    uint8_t Var1;
4
}T_MY_DATATYPE;

bzw. teile sie in 2 Teile auf
1
struct irgendwas
2
{
3
    uint8_t Var1;
4
};
5
6
typedef struct irgendwas T_MY_DATATYPE;

Eigentlich sollte das einen lint nicht stören, es ist auch im Original 
korrektes C, aber irgendwas stört den lint anscheinend hier.

BTW: der korrekte Header für memset wäre memory.h, nicht string.h

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

> Die Fehlermeldungen scheinen von den 'extern' Anweisungen in
> <string.h> auszugehen.

Was geschieht denn, wenn Du string.h erst nach dem typedef einbindest?

Dann sollten zumindest die ersten beiden Fehler (129 und 19) sich 
ändern.

von Matthias (Gast)


Lesenswert?

Hallo,
wenn ich den Header <string.h> nicht mehr einbinden bekomme ich keine 
Fehler mehr.
1
#include <stdint.h>
2
3
typedef struct
4
{
5
    uint8_t Var1;
6
}T_MY_DATATYPE;
7
8
void TestMain (void)
9
{
10
  T_MY_DATATYPE Test;
11
  Test.Var1 = 0;
12
13
  if (Test.Var1){};
14
15
  //memset (&Test, 0x00, sizeof(Test));
16
}
1
**** Build of configuration PC-Lint for project 01_Rfm12Test ****
2
3
C:\Programme\Lint\LINT-NT.EXE +v -u E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Project\Specific\Rfm12Test.lnt E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c 
4
PC-lint for C/C++ (NT) Ver. 8.00g, Copyright Gimpel Software 1985-2002
5
6
--- Module:   E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c
7
--- Module:   E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c
8
9
--- Global Wrap-up
10
11
 Note: Note 900 Successful completion, 0 messages produced

Die Debug-Ausgabe sieht dann folgendermaßen aus:
1
**** Build of configuration PC-Lint for project 01_Rfm12Test ****
2
3
C:\Programme\Lint\LINT-NT.EXE +v -u -p E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Project\Specific\Rfm12Test.lnt E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c 
4
PC-lint for C/C++ (NT) Ver. 8.00g, Copyright Gimpel Software 1985-2002
5
6
7
/* --- Module:   E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c */
8
--- Global Wrap-up
9
/*lint -e725*/
10
11
/*lint ++flb*/
12
13
E:\EclipseWorkspace\Workspace\01_Rfm12Test\Firmware\Application\Specific\Init\Test.c:17: Note: Note 900 Successful completion, 0 messages produced
14
typedef signed char int8_t;
15
typedef unsigned char uint8_t;
16
typedef signed int int16_t;
17
typedef unsigned int uint16_t;
18
typedef signed long int int32_t;
19
typedef unsigned long int uint32_t;
20
typedef signed long long int int64_t;
21
typedef unsigned long long int uint64_t;
22
typedef int16_t intptr_t;
23
typedef uint16_t uintptr_t;
24
typedef int8_t int_least8_t;
25
typedef uint8_t uint_least8_t;
26
typedef int16_t int_least16_t;
27
typedef uint16_t uint_least16_t;
28
typedef int32_t int_least32_t;
29
typedef uint32_t uint_least32_t;
30
typedef int64_t int_least64_t;
31
typedef uint64_t uint_least64_t;
32
typedef int8_t int_fast8_t;
33
typedef uint8_t uint_fast8_t;
34
typedef int16_t int_fast16_t;
35
typedef uint16_t uint_fast16_t;
36
typedef int32_t int_fast32_t;
37
typedef uint32_t uint_fast32_t;
38
typedef int64_t int_fast64_t;
39
typedef uint64_t uint_fast64_t;
40
typedef int64_t intmax_t;
41
typedef uint64_t uintmax_t;/*lint --flb*/
42
43
typedef struct
44
{
45
uint8_t Var1;
46
}T_MY_DATATYPE;
47
void TestMain (void)
48
{
49
T_MY_DATATYPE Test;
50
Test.Var1 = 0;
51
if (Test.Var1){};
52
}

Die Aufrufzeile ist folgende:
1
C:\Programme\Lint\LINT-NT.EXE +v -u  ${workspace_loc:/01_Rfm12Test}\Firmware\Project\Specific\Rfm12Test.lnt ${selected_resource_loc:}

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Tja, dann wird man sich wohl mal ansehen müssen, was in Deiner string.h 
so drinsteht. Ansonsten ist das alles recht merkwürdig.

von Matthias (Gast)


Lesenswert?

Es handelt sich um die standard Datei "string.h" die Bestandteil von 
WinAVR ist. In der Debug-Ausgabe wird direkt ausgegeben, welchen 
Quellcode PC-Lint prüft (inkl. der Header-Dateien).

Ich finde es auch echt merkwürdig. Darum habe ich mich ja auch an euch 
gewendet...

VG
Matthias

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.