My email
704975...@qq.com very very thank you.
Can you give me your files[kickstart32.s kmain.d linker32.ld makefile]?
My english is poor. My code to build is wrong.so need make some improvements. I would like to refer to your 32-bit code, make some improvements. My Email: 704975...@qq.com very very thank you.
I'm getting an unhelpful linker error, what've I got wrong?
When I attempt to compile my code I get the same linker error with both dmd and ldc2. I know where the problematic code is, as I don't get the error when I comment out lines 102 through 107, but I don't understand why it's bad. I must have some misconceptions about how templates work? Is there any way to get more descriptive errors out of the compiler if this sort of thing happens again in the future? Here's the code: http://pastebin.com/kGUPVa59 Here's the problematic lines: final streamint writestring(in char[] str){ return this.writebuffer!char(str.ptr, str.length); } final streamint writestring(in string str){ return this.writebuffer!char(str.ptr, str.length); } And the linker error: Undefined symbols for architecture x86_64: "_D6stream6Stream19__T11writebufferTaZ11writebufferMFxPaxlZl", referenced from: _D6stream6Stream11writestringMFxAaZl in stream.o _D6stream6Stream11writestringMFxAyaZl in stream.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1
Re: I'm getting an unhelpful linker error, what've I got wrong?
On Wednesday, 28 October 2015 at 11:11:01 UTC, pineapple wrote: When I attempt to compile my code I get the same linker error with both dmd and ldc2. I know where the problematic code is, as I don't get the error when I comment out lines 102 through 107, but I don't understand why it's bad. I must have some misconceptions about how templates work? Is there any way to get more descriptive errors out of the compiler if this sort of thing happens again in the future? Here's the code: http://pastebin.com/kGUPVa59 Here's the problematic lines: final streamint writestring(in char[] str){ return this.writebuffer!char(str.ptr, str.length); } final streamint writestring(in string str){ return this.writebuffer!char(str.ptr, str.length); } And the linker error: Undefined symbols for architecture x86_64: "_D6stream6Stream19__T11writebufferTaZ11writebufferMFxPaxlZl", referenced from: _D6stream6Stream11writestringMFxAaZl in stream.o _D6stream6Stream11writestringMFxAyaZl in stream.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1 The "writebuffer" is defined to take an array as parameter. Yet, you are passing a pointer and a length to it. Instead, pass the parameter "str" to it directly. Also, you do not have to put "!char" to there. Compiler will solve it out by itself.
Re: I'm getting an unhelpful linker error, what've I got wrong?
On Wednesday, 28 October 2015 at 11:40:14 UTC, tcak wrote: The "writebuffer" is defined to take an array as parameter. Yet, you are passing a pointer and a length to it. Instead, pass the parameter "str" to it directly. Also, you do not have to put "!char" to there. Compiler will solve it out by itself. There's also a writebuffer method in the interface with this signature, though: streamint writebuffer(T)(in T* buffer, in streamint count); And regardless, changing the problematic code to this doesn't address the linker error: final streamint writestring(in char[] str){ return this.writebuffer(str); } final streamint writestring(in string str){ return this.writebuffer(str); }
Re: I'm getting an unhelpful linker error, what've I got wrong?
On Wednesday, 28 October 2015 at 11:48:27 UTC, pineapple wrote: There's also a writebuffer method in the interface with this signature, though: streamint writebuffer(T)(in T* buffer, in streamint count); Interface can't have templated virtual instance methods.
Re: I'm getting an unhelpful linker error, what've I got wrong?
On Wednesday, 28 October 2015 at 11:48:27 UTC, pineapple wrote: On Wednesday, 28 October 2015 at 11:40:14 UTC, tcak wrote: The "writebuffer" is defined to take an array as parameter. Yet, you are passing a pointer and a length to it. Instead, pass the parameter "str" to it directly. Also, you do not have to put "!char" to there. Compiler will solve it out by itself. There's also a writebuffer method in the interface with this signature, though: streamint writebuffer(T)(in T* buffer, in streamint count); And regardless, changing the problematic code to this doesn't address the linker error: final streamint writestring(in char[] str){ return this.writebuffer(str); } final streamint writestring(in string str){ return this.writebuffer(str); } This still doesn't solve everything, but the first thing to do is to define a method for those in the interface as well. streamint writebuffer(T)(in T* buffer, in streamint count) streamint writebuffer(T)(in T* buffer, in streamint count, bool dynamic);
Re: I'm getting an unhelpful linker error, what've I got wrong?
On Wednesday, 28 October 2015 at 12:06:14 UTC, Kagamin wrote: On Wednesday, 28 October 2015 at 11:48:27 UTC, pineapple wrote: There's also a writebuffer method in the interface with this signature, though: streamint writebuffer(T)(in T* buffer, in streamint count); Interface can't have templated virtual instance methods. What might be my options for restructuring the code to avoid this, ideally without sacrificing functionality? I imagine I must be able to use a void pointer instead? But that's just ugly. Maybe I could do something like this? streamint writebuffer(in void* buffer, in streamint count); final streamint writebuffer(T){in T* buffer, in streamint count){ return this.writebuffer(cast(void*) buffer, sizeof(*buffer) * count); }
How coding bootloader with (Asm+Dlang)?
I would like to use (Dlang + nasm) to write bootloader, how to write?
Re: D bindings for Bonjour
On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote: Hi, I am starting my first project in D and I would like to do a Bonjour(Zeroconf) browser app. My first task is to write a binding to the dns_sd library but I have an issue with the following macro: #define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault) It justs takes some enum (defined above but not shown here) and do a OR operation on it. How can I express that in D ? Do I need to use a template as shown here http://wiki.dlang.org/D_binding_for_C or a varg function ? Thanks enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault); Good luck :)
Re: D bindings for Bonjour
On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote: On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote: [...] enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault); Good luck :) I wanted to delete my post when I realize the stupidity of my question. Actually I ask my question before really looking at it. Sorry
D bindings for Bonjour
Hi, I am starting my first project in D and I would like to do a Bonjour(Zeroconf) browser app. My first task is to write a binding to the dns_sd library but I have an issue with the following macro: #define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault) It justs takes some enum (defined above but not shown here) and do a OR operation on it. How can I express that in D ? Do I need to use a template as shown here http://wiki.dlang.org/D_binding_for_C or a varg function ? Thanks
Re: I'm getting an unhelpful linker error, what've I got wrong?
streamint writebuffer(in ubyte[] buffer); final streamint writebuffer(T)(in T* buffer, in streamint count){ return this.writebuffer(cast(ubyte[])buffer[0..count]); }
Re: D bindings for Bonjour
On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote: On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote: On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote: [...] enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault); Good luck :) I wanted to delete my post when I realize the stupidity of my question. Actually I ask my question before really looking at it. Sorry Is there any central place where you store bindings ?
Re: D bindings for Bonjour
V Wed, 28 Oct 2015 16:36:32 + Vincent R via Digitalmars-d-learn napsáno: > On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote: > > On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote: > >> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote: > >>> [...] > >> > >> enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | > >> kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing > >> | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault); > >> > >> Good luck :) > > > > I wanted to delete my post when I realize the stupidity of my > > question. Actually I ask my question before really looking at > > it. > > Sorry > > Is there any central place where you store bindings ? code.dlang.org -- general place for every d project
Re: D bindings for Bonjour
On Wednesday, 28 October 2015 at 16:53:15 UTC, Daniel Kozák wrote: V Wed, 28 Oct 2015 16:36:32 + Vincent R via Digitalmars-d-learn napsáno: On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote: > On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite > wrote: >> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R >> wrote: >>> [...] >> >> enum kDNSServiceOutputFlags = (kDNSServiceFlagsValidate | >> kDNSServiceFlagsValidateOptional | >> kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | >> kDNSServiceFlagsDefault); >> >> Good luck :) > > I wanted to delete my post when I realize the stupidity of my > question. Actually I ask my question before really looking at > it. > Sorry Is there any central place where you store bindings ? code.dlang.org -- general place for every d project Ok thanks. Sorry to ask so much question but how do you declare different calling conventions like the following macro: #if defined(_WIN32) #define DNSSD_API __stdcall #else #define DNSSD_API #endif From what I understand I could write: version (Windows) { extern (Windows) { int DNSServiceGetProperty ( in char *property, void *result, uint *size ); } } else { extern (C) { int DNSServiceGetProperty ( in char *property, void *result, uint *size ); } } but I don't want to write it once. How can I solve this ? And if there is an easy fix what about writing it inside the wiki page: http://wiki.dlang.org/D_binding_for_C Thanks
Re: D bindings for Bonjour
On Wednesday, 28 October 2015 at 17:07:32 UTC, Vincent R wrote: Sorry to ask so much question but how do you declare different calling conventions like the following macro: This specific case is common enough to be built into the language: use `extern(System)` instead of Windows or C and the one declaration will work on both. And if there is an easy fix what about writing it inside the wiki page: http://wiki.dlang.org/D_binding_for_C You can edit a wiki yourself!
Re: How coding bootloader with (Asm+Dlang)?
On Wednesday, 28 October 2015 at 15:23:11 UTC, guodemone wrote: I would like to use (Dlang + nasm) to write bootloader, how to write? Start from here: http://wiki.osdev.org/D_Bare_Bones I would suggest you to start by learning to do it with C first though. There are too many documents about this already. This way, you can make the conversion from C to D much easy later.
Get type from string
Example: class Bob { static void print () { write("str"); } } string name = "Bob"; __traits(getMember, Types.getType(name), "print")(); How can you implement "Types.getType(name)"? I do not know in advance what can be the class names.
Re: Get type from string
On Wednesday, 28 October 2015 at 17:38:45 UTC, DarkRiDDeR wrote: string name = "Bob"; __traits(getMember, Types.getType(name), "print")(); How can you implement "Types.getType(name)"? I do not know in advance what can be the class names. You don't. __traits works at compile time, the string isn't known until run time. If you can rewrite it to use an interface, you can make that work though. interface Printable { void print(); } class Bob : Printable { void print() { writeln("hey"); } } void main() { string name = "test.Bob"; // module name needed Printable printable = cast(Printable) Object.factory(name); if(printable is null) throw new Exception("bad class"); printable.print(); } Object.factory's neck is on the chopping block, but it might stick around anyway, and even if it goes away there will be an alternative. You could register classes in your own code, for example. Regardless, this is a solution for now.
Re: Get type from string
Thank you! Is it possible to call a method from a string at run time?
Re: Get type from string
On Wednesday, 28 October 2015 at 17:57:16 UTC, DarkRiDDeR wrote: Thank you! Is it possible to call a method from a string at run time? Yes, though you have to prepare code to do it. Again, I'd try to make it work on interfaces on some level. The free sample chapter of my book https://www.packtpub.com/application-development/d-cookbook shows an example near the end of how to write that code. Basically, you loop over members at compile time and generate wrapper functions for them, which you then call based on a runtime string.
Re: Can you give me your files[kickstart32.s kmain.d linker32.ld makefile]?
On Wednesday, 28 October 2015 at 11:01:14 UTC, guodemone wrote: My english is poor. My code to build is wrong.so need make some improvements. I would like to refer to your 32-bit code, make some improvements. My Email: 704975...@qq.com very very thank you. I've uploaded a dummy kernel with bootloader to Github. Hopefully it will help you. https://github.com/swamplobo/lyrebirdos A few points: * The Makefile uses DMD but if you prefer you can use the gdc_Makefile to switch compilers easily. * This example uses GRUB, which you can replace this if you wish. I did once I got things working (I've now gone back to GRUB because it has some nice features). * I use qemu, VirtualBox and real hardware to test. I recommend testing in a VM before trying real hardware. * The name Lyrebird OS is just the name I chose, rename to whatever you like. * Keep at it because it's very rewarding watching your own kernel grow. bye, lobo
very very thank you
衷心的谢谢你,(very veryvery thank you in english)