digitalmars.D - D vs C Char
- Trevor Parscal (12/12) Jun 29 2005 OK, so I am still having trouble with this FreeType library, and ... The...
- Unknown W. Brackets (2/13) Jun 29 2005
- Brad Beveridge (13/24) Jun 29 2005 That smells like a bogus answer to me. Nobody in their right mind
- Trevor Parscal (17/46) Jun 29 2005 Thats a good question.. I suppose I should try and do a test with C..
- Brad Beveridge (19/35) Jun 29 2005 The documentation has some snippet code examples that look like they'd
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (19/25) Jun 29 2005 No, as the various D integer initializers are still sane... :-)
- Trevor Parscal (8/13) Jun 29 2005 I would be VERY interested in seeing what you come up with.. Send me a
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (7/9) Jun 29 2005 They are using macros for *everything*, including names of headers -
- Trevor Parscal (7/22) Jun 29 2005 yes.. Yay UNIX, BOOO Windows...
- Mike Parker (4/8) Jun 29 2005 Install Cygwin or MingW + MSYS on Windows and you can do the same thing:...
- brad beveridge (4/14) Jun 29 2005 True, but in the past I have found that cygwin is a poor substitute for
- Trevor Parscal (10/27) Jun 29 2005 Yes, MSSYS and ctgwin have both been less than satisfying..
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (18/25) Jun 30 2005 No go, sorry. There's just too many macros used (worse than SDL!)
- Bruno Medeiros (6/17) Jul 03 2005 May I ask you why are you using the FreeType library? And also why are
OK, so I am still having trouble with this FreeType library, and ... The people from the FreeType newsgroup told me.. - do not use the D 'char' for C 'char'. That's because it's default initializer is 0xFF instead of 0, and this will cause all kinds of subtle problems when used naively in D code. So what do i use instead? byte? Isn't the intializer the same? -- Thanks, Trevor Parscal www.trevorparscal.com trevorparscal hotmail.com
Jun 29 2005
I would use ubyte... -[Unknown]OK, so I am still having trouble with this FreeType library, and ... The people from the FreeType newsgroup told me.. - do not use the D 'char' for C 'char'. That's because it's default initializer is 0xFF instead of 0, and this will cause all kinds of subtle problems when used naively in D code. So what do i use instead? byte? Isn't the intializer the same?
Jun 29 2005
Trevor Parscal wrote:OK, so I am still having trouble with this FreeType library, and ... The people from the FreeType newsgroup told me.. - do not use the D 'char' for C 'char'. That's because it's default initializer is 0xFF instead of 0, and this will cause all kinds of subtle problems when used naively in D code. So what do i use instead? byte? Isn't the intializer the same?That smells like a bogus answer to me. Nobody in their right mind should rely on a C compiler to initialise variables. The only difference between C's char and D's char is that D explicitly defines char to be unsigned, a C compiler may choose to define it as signed or unsigned, depending on architecture/whim. If there is truely a difference between the default init value, then you can explicitly set the variable. char c = 0; BTW, have you got a simple working C example of Freetype that works? Can you convert that to D? I'm wondering if you're having troubles because of misusing the Freetype API rather than the C/D interface. Brad
Jun 29 2005
Brad Beveridge wrote:Trevor Parscal wrote:Thats a good question.. I suppose I should try and do a test with C.. But, its allot of configuration crap just to get FreeType to compile with C at all.. so.. I have been avoiding dealing with that. They say on the FreeType page, "FreeType will compile on almost any compiler on most platforms without even a single warning".. But, my experience is that it's EXTRMELY difficult to get it to compile at all, and there are so many warnings its hard to see where the errors are. Anyhoo, I cant even begin to explain how much I wish this worked, and would give my semicolin key to the man who helps me do so. Thanks, Trevor Parscal -- Thanks, Trevor Parscal www.trevorparscal.com trevorparscal hotmail.comOK, so I am still having trouble with this FreeType library, and ... The people from the FreeType newsgroup told me.. - do not use the D 'char' for C 'char'. That's because it's default initializer is 0xFF instead of 0, and this will cause all kinds of subtle problems when used naively in D code. So what do i use instead? byte? Isn't the intializer the same?That smells like a bogus answer to me. Nobody in their right mind should rely on a C compiler to initialise variables. The only difference between C's char and D's char is that D explicitly defines char to be unsigned, a C compiler may choose to define it as signed or unsigned, depending on architecture/whim. If there is truely a difference between the default init value, then you can explicitly set the variable. char c = 0; BTW, have you got a simple working C example of Freetype that works? Can you convert that to D? I'm wondering if you're having troubles because of misusing the Freetype API rather than the C/D interface. Brad
Jun 29 2005
Trevor Parscal wrote: <snip>Thats a good question.. I suppose I should try and do a test with C.. But, its allot of configuration crap just to get FreeType to compile with C at all.. so.. I have been avoiding dealing with that. They say on the FreeType page, "FreeType will compile on almost any compiler on most platforms without even a single warning".. But, my experience is that it's EXTRMELY difficult to get it to compile at all, and there are so many warnings its hard to see where the errors are. Anyhoo, I cant even begin to explain how much I wish this worked, and would give my semicolin key to the man who helps me do so. Thanks, Trevor ParscalThe documentation has some snippet code examples that look like they'd go together without much trouble. I did notice one interesting thing, the docs say you should #include <ftbuild2.h> #include FT_FREETYPE_H which looks a little weird to me, I think they are doing some non standard things, and they mention that they are doing magic trickery. I think that my approach to this would be 1) Write a C program that gets free type working 2) Convert that program to something more like a library, so that it proxies the free type calls that you are actually interested in. 3) Interface your D code to this proxy library/object file. 4) Start directly interfacing to Freetype from D where appropriate. Unless I understood what was going on in the headers really well, I'd try and take the above approach. Cheers Brad
Jun 29 2005
Trevor Parscal wrote:- do not use the D 'char' for C 'char'. That's because it's default initializer is 0xFF instead of 0, and this will cause all kinds of subtle problems when used naively in D code. So what do i use instead? byte? Isn't the intializer the same?No, as the various D integer initializers are still sane... :-) It's just the code units and floating points that's "wild". (As per the table at http://www.digitalmars.com/d/type.html) It all depends on what they are using "char" for, really ? If it's ASCII, then _either_ "char" or "ubyte" will do fine. If they are using char for 8-bit encodings, then it's ubyte. And if they are using char for UTF-8 (unlikely), then: char. And for "char*", it doesn't matter much at all really (since you get a pointer), so most people just stick with the C def. Even if it's technically wrong in D, since "char*" means UTF-8. (and not "some random encoding", like its the old C meaning is) That being said, I haven't had a problem translating C's "char*" to D's "char*", in any of the import modules for D that I have done thus far... I'll feed the freetype2 headers to my C header->D module script, and see what it comes up with. Minus the weirdo macros, that is. But don't hold your breath. ;-) --anders
Jun 29 2005
Anders F Björklund wrote:I'll feed the freetype2 headers to my C header->D module script, and see what it comes up with. Minus the weirdo macros, that is. But don't hold your breath. ;-) --andersI would be VERY interested in seeing what you come up with.. Send me a copy if you can once it is under control, or when you give up... -- Thanks, Trevor Parscal www.trevorparscal.com trevorparscal hotmail.com
Jun 29 2005
Trevor Parscal wrote:I would be VERY interested in seeing what you come up with.. Send me a copy if you can once it is under control, or when you give up...They are using macros for *everything*, including names of headers - so it needs to be preprocessed after conversion... <mutter, mutter> (I'm not preprocessing before conversion, since the #defines usually holds a lot of usable information that can be converted into D things) Wasn't very hard to compile, though ? "./configure && make". Yay, UNIX. --anders
Jun 29 2005
Anders F Björklund wrote:Trevor Parscal wrote:yes.. Yay UNIX, BOOO Windows... -- Thanks, Trevor Parscal www.trevorparscal.com trevorparscal hotmail.comI would be VERY interested in seeing what you come up with.. Send me a copy if you can once it is under control, or when you give up...They are using macros for *everything*, including names of headers - so it needs to be preprocessed after conversion... <mutter, mutter> (I'm not preprocessing before conversion, since the #defines usually holds a lot of usable information that can be converted into D things) Wasn't very hard to compile, though ? "./configure && make". Yay, UNIX. --anders
Jun 29 2005
Trevor Parscal wrote:yes.. Yay UNIX, BOOO Windows...Install Cygwin or MingW + MSYS on Windows and you can do the same thing: ./configure make
Jun 29 2005
Mike Parker wrote:Trevor Parscal wrote:True, but in the past I have found that cygwin is a poor substitute for the real thing :) Bradyes.. Yay UNIX, BOOO Windows...Install Cygwin or MingW + MSYS on Windows and you can do the same thing: ./configure make
Jun 29 2005
brad beveridge wrote:Mike Parker wrote:Yes, MSSYS and ctgwin have both been less than satisfying.. besides, compiling on linux / unix isn't what I needed to do with FreeType... I needed to compile it on Windows, for windows... thus.. BOOO Windows... :) -- Thanks, Trevor Parscal www.trevorparscal.com trevorparscal hotmail.comTrevor Parscal wrote:True, but in the past I have found that cygwin is a poor substitute for the real thing :) Bradyes.. Yay UNIX, BOOO Windows...Install Cygwin or MingW + MSYS on Windows and you can do the same thing: ./configure make
Jun 29 2005
Trevor Parscal wrote:No go, sorry. There's just too many macros used (worse than SDL!) So I think you are better off with your hand-translated version ? (last time I heard, you were still trying to get it to link with a test C program or something, so that would probably be step one) I have a similar problem here on Mac OS X, with the "Carbon" headers that use some C features which makes them hard to port over to D :-( They work just fine from C, C++, and Objective-C too; but require some hand-holding to work with D. I've done selected functions, but not all. Unfortunately, this makes D much less useful - when it can't use C libs. It's of course doable to write the import modules, just a *lot* of work? Another problem in this particular case is that they are copyrighted, so even if I do get them ported I'm not sure I'm allowed to redistribute... But at least this is one of the "known issues" with the D language. " These are some of the major bugs: Need to write a tool to convert C .h files into D imports. " (From http://www.digitalmars.com/d/dcompiler.html#general) --andersI'll feed the freetype2 headers to my C header->D module script, and see what it comes up with. Minus the weirdo macros, that is. But don't hold your breath. ;-)I would be VERY interested in seeing what you come up with.. Send me a copy if you can once it is under control, or when you give up...
Jun 30 2005
Trevor Parscal wrote:OK, so I am still having trouble with this FreeType library, and ... The people from the FreeType newsgroup told me.. - do not use the D 'char' for C 'char'. That's because it's default initializer is 0xFF instead of 0, and this will cause all kinds of subtle problems when used naively in D code. So what do i use instead? byte? Isn't the intializer the same?May I ask you why are you using the FreeType library? And also why are you compiling it, is that necessary to use it? -- Bruno Medeiros Computer Science/Engineering student
Jul 03 2005