Skip to content

Commit ae7461a

Browse files
committed
M27-0-1: Address compiler compatibility
Modify cstdio to more closely match real compilers.
1 parent 070579a commit ae7461a

File tree

4 files changed

+152
-153
lines changed

4 files changed

+152
-153
lines changed

cpp/autosar/test/rules/M27-0-1/CstdioFunctionsUsed.expected

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
| test.cpp:4:18:4:27 | call to fopen | Use of <cstdio> function 'std::fopen'. |
2-
| test.cpp:7:3:7:14 | call to fgetpos | Use of <cstdio> function 'std::fgetpos'. |
3-
| test.cpp:9:11:9:19 | call to feof | Use of <cstdio> function 'std::feof'. |
4-
| test.cpp:10:14:10:23 | call to fgetc | Use of <cstdio> function 'std::fgetc'. |
5-
| test.cpp:12:7:12:17 | call to rewind | Use of <cstdio> function 'std::rewind'. |
6-
| test.cpp:14:7:14:17 | call to ferror | Use of <cstdio> function 'std::ferror'. |
7-
| test.cpp:15:5:15:17 | call to clearerr | Use of <cstdio> function 'std::clearerr'. |
8-
| test.cpp:16:5:16:15 | call to fclose | Use of <cstdio> function 'std::fclose'. |
9-
| test.cpp:17:5:17:15 | call to perror | Use of <cstdio> function 'std::perror'. |
10-
| test.cpp:20:3:20:12 | call to fseek | Use of <cstdio> function 'std::fseek'. |
11-
| test.cpp:21:3:21:12 | call to fseek | Use of <cstdio> function 'std::fseek'. |
12-
| test.cpp:23:3:23:12 | call to fread | Use of <cstdio> function 'std::fread'. |
13-
| test.cpp:25:3:25:14 | call to fsetpos | Use of <cstdio> function 'std::fsetpos'. |
14-
| test.cpp:26:3:26:13 | call to fflush | Use of <cstdio> function 'std::fflush'. |
15-
| test.cpp:27:3:27:13 | call to fclose | Use of <cstdio> function 'std::fclose'. |
16-
| test.cpp:29:3:29:13 | call to printf | Use of <cstdio> function 'std::printf'. |
17-
| test.cpp:31:3:31:11 | call to puts | Use of <cstdio> function 'std::puts'. |
1+
| test.cpp:4:18:4:27 | call to fopen | Use of <cstdio> function 'fopen'. |
2+
| test.cpp:7:3:7:14 | call to fgetpos | Use of <cstdio> function 'fgetpos'. |
3+
| test.cpp:9:11:9:19 | call to feof | Use of <cstdio> function 'feof'. |
4+
| test.cpp:10:14:10:23 | call to fgetc | Use of <cstdio> function 'fgetc'. |
5+
| test.cpp:12:7:12:17 | call to rewind | Use of <cstdio> function 'rewind'. |
6+
| test.cpp:14:7:14:17 | call to ferror | Use of <cstdio> function 'ferror'. |
7+
| test.cpp:15:5:15:17 | call to clearerr | Use of <cstdio> function 'clearerr'. |
8+
| test.cpp:16:5:16:15 | call to fclose | Use of <cstdio> function 'fclose'. |
9+
| test.cpp:17:5:17:15 | call to perror | Use of <cstdio> function 'perror'. |
10+
| test.cpp:20:3:20:12 | call to fseek | Use of <cstdio> function 'fseek'. |
11+
| test.cpp:21:3:21:12 | call to fseek | Use of <cstdio> function 'fseek'. |
12+
| test.cpp:23:3:23:12 | call to fread | Use of <cstdio> function 'fread'. |
13+
| test.cpp:25:3:25:14 | call to fsetpos | Use of <cstdio> function 'fsetpos'. |
14+
| test.cpp:26:3:26:13 | call to fflush | Use of <cstdio> function 'fflush'. |
15+
| test.cpp:27:3:27:13 | call to fclose | Use of <cstdio> function 'fclose'. |
16+
| test.cpp:29:3:29:13 | call to printf | Use of <cstdio> function 'printf'. |
17+
| test.cpp:31:3:31:11 | call to puts | Use of <cstdio> function 'puts'. |
1818
| test.cpp:34:14:34:18 | call to fopen | Use of <cstdio> function 'fopen'. |
1919
| test.cpp:37:3:37:9 | call to fgetpos | Use of <cstdio> function 'fgetpos'. |
2020
| test.cpp:39:11:39:14 | call to feof | Use of <cstdio> function 'feof'. |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| test.cpp:4:8:4:11 | type mention | Use of <cstdio> type 'std::FILE'. |
2-
| test.cpp:6:8:6:13 | type mention | Use of <cstdio> type 'std::fpos_t'. |
1+
| test.cpp:4:8:4:11 | type mention | Use of <cstdio> type 'FILE'. |
2+
| test.cpp:6:8:6:13 | type mention | Use of <cstdio> type 'fpos_t'. |
33
| test.cpp:34:3:34:6 | type mention | Use of <cstdio> type 'FILE'. |
44
| test.cpp:36:3:36:8 | type mention | Use of <cstdio> type 'fpos_t'. |

cpp/common/test/includes/standard-library/cstdio

Lines changed: 51 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -16,135 +16,55 @@
1616
#define SEEK_END -1
1717
#define stderr 0
1818

19-
namespace std {
20-
struct FILE;
21-
typedef int fpos_t;
22-
23-
// Operations on files
24-
int remove(const char *filename);
25-
int rename(const char *oldname, const char *newname);
26-
FILE *tmpfile(void);
27-
char *tmpnam(char *str);
28-
29-
// File access
30-
int fclose(FILE *stream);
31-
int fflush(FILE *stream);
32-
FILE *fopen(const char *filename, const char *mode);
33-
FILE *freopen(const char *filename, const char *mode, FILE *stream);
34-
void setbuf(FILE *stream, char *buffer);
35-
int setvbuf(FILE *stream, char *buffer, int mode, size_t size);
36-
37-
// Formatted input/output
38-
int fprintf(FILE *stream, const char *format, ...);
39-
int fscanf(FILE *stream, const char *format, ...);
40-
int printf(const char *format, ...);
41-
int scanf(const char *format, ...);
42-
int snprintf(char *s, size_t n, const char *format, ...);
43-
int sprintf(char *str, const char *format, ...);
44-
int sscanf(const char *s, const char *format, ...);
45-
/*
46-
int vfprintf ( FILE * stream, const char * format, va_list arg );
47-
int vfscanf ( FILE * stream, const char * format, va_list arg );
48-
int vprintf ( const char * format, va_list arg );
49-
int vscanf ( const char * format, va_list arg );
50-
int vsnprintf (char * s, size_t n, const char * format, va_list arg );
51-
int vsprintf (char * s, const char * format, va_list arg );
52-
int vsscanf ( const char * s, const char * format, va_list arg );
53-
*/
54-
55-
// Character input/output
56-
int fgetc(FILE *stream);
57-
char *fgets(char *str, int num, FILE *stream);
58-
int fputc(int character, FILE *stream);
59-
int fputs(const char *str, FILE *stream);
60-
int getc(FILE *stream);
61-
int getchar(void);
62-
char *gets(char *str);
63-
int putc(int character, FILE *stream);
64-
int putchar(int character);
65-
int puts(const char *str);
66-
int ungetc(int character, FILE *stream);
67-
68-
// Direct input/output
69-
size_t fread(void *ptr, size_t size, size_t count, FILE *stream);
70-
size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream);
71-
72-
// File positioning
73-
int fgetpos(FILE *stream, fpos_t *pos);
74-
int fseek(FILE *stream, long int offset, int origin);
75-
int fsetpos(FILE *stream, const fpos_t *pos);
76-
long int ftell(FILE *stream);
77-
void rewind(FILE *stream);
78-
79-
// Error-handling
80-
void clearerr(FILE *stream);
81-
int feof(FILE *stream);
82-
int ferror(FILE *stream);
83-
void perror(const char *str);
84-
} // namespace std
19+
#include <stdio.h>
8520

86-
// global namespace
87-
struct FILE;
88-
typedef int fpos_t;
89-
90-
// Operations on files
91-
int remove(const char *filename);
92-
int rename(const char *oldname, const char *newname);
93-
FILE *tmpfile(void);
94-
char *tmpnam(char *str);
95-
96-
// File access
97-
int fclose(FILE *stream);
98-
int fflush(FILE *stream);
99-
FILE *fopen(const char *filename, const char *mode);
100-
FILE *freopen(const char *filename, const char *mode, FILE *stream);
101-
void setbuf(FILE *stream, char *buffer);
102-
int setvbuf(FILE *stream, char *buffer, int mode, size_t size);
103-
104-
// Formatted input/output
105-
int fprintf(FILE *stream, const char *format, ...);
106-
int fscanf(FILE *stream, const char *format, ...);
107-
int printf(const char *format, ...);
108-
int scanf(const char *format, ...);
109-
int snprintf(char *s, size_t n, const char *format, ...);
110-
int sprintf(char *str, const char *format, ...);
111-
int sscanf(const char *s, const char *format, ...);
112-
/*
113-
int vfprintf ( FILE * stream, const char * format, va_list arg );
114-
int vfscanf ( FILE * stream, const char * format, va_list arg );
115-
int vprintf ( const char * format, va_list arg );
116-
int vscanf ( const char * format, va_list arg );
117-
int vsnprintf (char * s, size_t n, const char * format, va_list arg );
118-
int vsprintf (char * s, const char * format, va_list arg );
119-
int vsscanf ( const char * s, const char * format, va_list arg );
120-
*/
121-
122-
// Character input/output
123-
int fgetc(FILE *stream);
124-
char *fgets(char *str, int num, FILE *stream);
125-
int fputc(int character, FILE *stream);
126-
int fputs(const char *str, FILE *stream);
127-
int getc(FILE *stream);
128-
int getchar(void);
129-
char *gets(char *str);
130-
int putc(int character, FILE *stream);
131-
int putchar(int character);
132-
int puts(const char *str);
133-
int ungetc(int character, FILE *stream);
134-
135-
// Direct input/output
136-
size_t fread(void *ptr, size_t size, size_t count, FILE *stream);
137-
size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream);
138-
139-
// File positioning
140-
int fgetpos(FILE *stream, fpos_t *pos);
141-
int fseek(FILE *stream, long int offset, int origin);
142-
int fsetpos(FILE *stream, const fpos_t *pos);
143-
long int ftell(FILE *stream);
144-
void rewind(FILE *stream);
145-
146-
// Error-handling
147-
void clearerr(FILE *stream);
148-
int feof(FILE *stream);
149-
int ferror(FILE *stream);
150-
void perror(const char *str);
21+
namespace std {
22+
using ::FILE;
23+
using ::fpos_t;
24+
25+
using ::remove;
26+
using ::rename;
27+
using ::tmpfile;
28+
using ::tmpnam;
29+
30+
using ::fclose;
31+
using ::fflush;
32+
using ::fopen;
33+
using ::freopen;
34+
using ::setbuf;
35+
using ::setvbuf;
36+
37+
using ::fprintf;
38+
using ::fscanf;
39+
using ::printf;
40+
using ::scanf;
41+
using ::snprintf;
42+
using ::sprintf;
43+
using ::sscanf;
44+
45+
using ::fgetc;
46+
using ::fgets;
47+
using ::fputc;
48+
using ::fputs;
49+
using ::getc;
50+
using ::getchar;
51+
using ::gets;
52+
using ::putc;
53+
using ::putchar;
54+
using ::puts;
55+
using ::ungetc;
56+
57+
using ::fread;
58+
using ::fwrite;
59+
60+
using ::fgetpos;
61+
using ::fseek;
62+
using ::fsetpos;
63+
using ::ftell;
64+
using ::rewind;
65+
66+
using ::clearerr;
67+
using ::feof;
68+
using ::ferror;
69+
using ::perror;
70+
} // namespace std
Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,84 @@
1+
#ifndef _GHLIBCPP_STDIO
2+
#define _GHLIBCPP_STDIO
3+
4+
#include <stddef.h>
5+
16
typedef void FILE;
7+
typedef int fpos_t;
8+
9+
// Operations on files
10+
int remove(const char *filename);
11+
int rename(const char *oldname, const char *newname);
12+
FILE *tmpfile(void);
13+
char *tmpnam(char *str);
14+
15+
// File access
16+
int fclose(FILE *stream);
17+
int fflush(FILE *stream);
18+
FILE *fopen(const char *filename, const char *mode);
19+
FILE *freopen(const char *filename, const char *mode, FILE *stream);
20+
void setbuf(FILE *stream, char *buffer);
21+
int setvbuf(FILE *stream, char *buffer, int mode, size_t size);
22+
23+
// Formatted input/output
24+
int fprintf(FILE *stream, const char *format, ...);
25+
int fscanf(FILE *stream, const char *format, ...);
26+
int printf(const char *format, ...);
27+
int scanf(const char *format, ...);
28+
int snprintf(char *s, size_t n, const char *format, ...);
29+
int sprintf(char *str, const char *format, ...);
30+
int sscanf(const char *s, const char *format, ...);
31+
/*
32+
int vfprintf ( FILE * stream, const char * format, va_list arg );
33+
int vfscanf ( FILE * stream, const char * format, va_list arg );
34+
int vprintf ( const char * format, va_list arg );
35+
int vscanf ( const char * format, va_list arg );
36+
int vsnprintf (char * s, size_t n, const char * format, va_list arg );
37+
int vsprintf (char * s, const char * format, va_list arg );
38+
int vsscanf ( const char * s, const char * format, va_list arg );
39+
*/
40+
41+
// Character input/output
42+
int fgetc(FILE *stream);
43+
char *fgets(char *str, int num, FILE *stream);
44+
int fputc(int character, FILE *stream);
45+
int fputs(const char *str, FILE *stream);
46+
int getc(FILE *stream);
47+
int getchar(void);
48+
char *gets(char *str);
49+
int putc(int character, FILE *stream);
50+
int putchar(int character);
51+
int puts(const char *str);
52+
int ungetc(int character, FILE *stream);
53+
54+
// Character input/output
55+
int fgetc(FILE *stream);
56+
char *fgets(char *str, int num, FILE *stream);
57+
int fputc(int character, FILE *stream);
58+
int fputs(const char *str, FILE *stream);
59+
int getc(FILE *stream);
60+
int getchar(void);
61+
char *gets(char *str);
62+
int putc(int character, FILE *stream);
63+
int putchar(int character);
64+
int puts(const char *str);
65+
int ungetc(int character, FILE *stream);
66+
67+
// Direct input/output
68+
size_t fread(void *ptr, size_t size, size_t count, FILE *stream);
69+
size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream);
70+
71+
// File positioning
72+
int fgetpos(FILE *stream, fpos_t *pos);
73+
int fseek(FILE *stream, long int offset, int origin);
74+
int fsetpos(FILE *stream, const fpos_t *pos);
75+
long int ftell(FILE *stream);
76+
void rewind(FILE *stream);
77+
78+
// Error-handling
79+
void clearerr(FILE *stream);
80+
int feof(FILE *stream);
81+
int ferror(FILE *stream);
82+
void perror(const char *str);
283

3-
FILE *fopen(const char *, const char *);
4-
int fclose(FILE *);
5-
int remove(const char *);
84+
#endif // _GHLIBCPP_STDIO

0 commit comments

Comments
 (0)