Hi all,
I've just committed a few changes to the ntfsprogs.
I've added compat.[ch] to hide a host of minor tweaks that will be
needed to get things to compile on Windows. This is enough to get
around most of the GCCisms of the code, e.g. __attribute__.
One thing I've had to change is the reliance on void * arithmetic.
I was quite alarmed when I realised that gcc allows:
void *v = "abc";
v++;
It seems that they've decided to define sizeof (void) == 1. Sensible,
but I don't think it's a standard. At the moment, I've just cast the
pointers to (u8*). A warning for this can be turned on using
-Wpointer-arith
We also seem to be relying on the size of __packed__ enums. It's a
nice feature, but it's another gcc extension. In our code we can:
typedef enum {
ABC = 4,
} RICH __attribute__ ((__packed__));
The size of the type for the enum will be minimised, in this case to
1 byte. Then we can use it in a struct, e.g.:
struct x {
int a;
RICH r;
int b;
};
We rely on the enum being just one byte, but that's not portable.
One solution is to create and use the enumeration, but create a
strictly sized type for the struct, e.g.
enum rich {
ABC = 4,
};
typedef u8 RICH;
struct x {
int a;
RICH r;
int b;
};
The next problem is the casting of parameters for Dprintf. At the
moment a lot of variables are cast to long long. Windows doesn't
like "long long" and prefers "__int64". Being two words, I can't
#define my way out of this.
I remember some reason (in kernel space) for this casting. Some reason
why we couldn't use the pre-defined types. Anton? Now we're in
userspace, can we change:
Dprintf ("Big number %Lu\n", (unsigned long long) num);
to:
Dprintf ("Big number %Lu\n", (u64) num);
If not, can we not simply #define our types instead of typedef'ing them?
Cheers,
FlatCap (Rich)
nt...@fl...
WWW: http://linux-ntfs.sf.net
IRC: #ntfs on irc.freenode.net
|