Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Linux .brc handling bug
Re: Linux .brc handling bug [message #7276 is a reply to message #6396] |
Wed, 20 December 2006 00:06  |
Balage
Messages: 17 Registered: December 2006
|
Promising Member |
|
|
BINARY_MASK is also dangerous.
#define BINARY_MASK(i, m) \
extern "C" byte *i[]; \
extern "C" int COMBINE(i, _length)[]; \
extern "C" int COMBINE(i, _count); \
extern "C" char *COMBINE(i, _files)[];
The xxx_files part is generated like this:
char *xxx_files[] = {
"File1.cpp",
"File2.cpp",
};
That's an array of pointers, pointing to string literals. And string literals are const. So trying to modify xxx_files[i][n] also segfaults.
The solution is to either:
- Modify type to this: const char* xxx_files[]
(This also means to modify BINARY_MASK macro)
Or:
- Generate an array for each filename, then add those to xxx_files, like this:
static char xxx_file_1[] = "File1.cpp";
static char xxx_file_2[] = "File2.cpp";
char *xxx_files[] = {
xxx_file_1,
xxx_file_2,
};
Anyway, I also think that byte should be replaced with char, as that's what is used for the definition.
The current fix:
#define BINARY(i, f) \
extern "C" char i[]; \
extern "C" int COMBINE(i, _length);
#define BINARY_ARRAY(i, x, f) \
extern "C" char *i[]; \
extern "C" int COMBINE(i, _length)[]; \
extern "C" int COMBINE(i, _count);
#define BINARY_MASK(i, m) \
extern "C" char *i[]; \
extern "C" int COMBINE(i, _length)[]; \
extern "C" int COMBINE(i, _count); \
extern "C" const char *COMBINE(i, _files)[];
This makes types correct, so you don't accidentally segfault.
[Updated on: Wed, 20 December 2006 00:16] Report message to a moderator
|
|
|
 |
|
Linux .brc handling bug
By: zsolt on Fri, 10 November 2006 14:13
|
 |
|
Re: Linux .brc handling bug
By: mirek on Sat, 11 November 2006 13:42
|
 |
|
Re: Linux .brc handling bug
By: zsolt on Sat, 11 November 2006 15:02
|
 |
|
Re: Linux .brc handling bug
By: zsolt on Sat, 11 November 2006 15:36
|
 |
|
Re: Linux .brc handling bug
By: zsolt on Tue, 19 December 2006 14:13
|
 |
|
Re: Linux .brc handling bug
By: Balage on Tue, 19 December 2006 15:37
|
 |
|
Re: Linux .brc handling bug
By: zsolt on Tue, 19 December 2006 18:41
|
 |
|
Re: Linux .brc handling bug
By: Balage on Tue, 19 December 2006 19:23
|
 |
|
Re: Linux .brc handling bug
By: zsolt on Tue, 19 December 2006 20:56
|
 |
|
Re: Linux .brc handling bug
By: mirek on Tue, 19 December 2006 21:26
|
 |
|
Re: Linux .brc handling bug
By: Balage on Tue, 19 December 2006 22:36
|
 |
|
Re: Linux .brc handling bug
By: mirek on Tue, 19 December 2006 23:36
|
 |
|
Re: Linux .brc handling bug
By: Balage on Wed, 20 December 2006 00:06
|
Goto Forum:
Current Time: Sun Aug 10 07:13:24 CEST 2025
Total time taken to generate the page: 0.03219 seconds
|