On Thursday, 21 March 2024 at 18:19:58 UTC, Carl Sturtivant wrote:
On Thursday, 21 March 2024 at 00:06:56 UTC, Carl Sturtivant
wrote:
```C
EXTERN_GUID(IID_IBlahBlahBlah, 0xabcdef12, 0x11d2, 0xab3a,
0xc0, 0x4f, [...] );
```
Has anyone successfully compiled an EXTERN_GUID declaration
like thi
On Friday, 16 June 2023 at 16:25:35 UTC, Dmitry Olshansky wrote:
On Friday, 16 June 2023 at 16:14:19 UTC, Steven Schveighoffer
wrote:
On 6/16/23 11:56 AM, Dmitry Olshansky wrote:
Any advice from MacOS users?
Yep.
Go into settings, then privacy and security. Make sure "App
store and identif
On Sunday, 12 December 2021 at 07:40:10 UTC, ManKey wrote:
On Saturday, 11 December 2021 at 22:28:16 UTC, forkit wrote:
On Saturday, 11 December 2021 at 21:42:49 UTC, ManKey wrote:
umm... the site has search function you know ;-)
Dude, you see, it doesn't say anything about it. It says a
litt
On Monday, 6 December 2021 at 18:38:37 UTC, Ola Fosheim Grøstad
wrote:
On Monday, 6 December 2021 at 17:46:35 UTC, Dave P. wrote:
I’m porting some C code which uses the gcc intrinsics to do a
multiply/add with overflow checking. See
[here](https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow
I’m porting some C code which uses the gcc intrinsics to do a
multiply/add with overflow checking. See
[here](https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html) for reference. Is there a D equivalent?
On Friday, 22 October 2021 at 06:11:35 UTC, data pulverizer wrote:
On Thursday, 21 October 2021 at 23:06:18 UTC, jfondren wrote:
[...]
I've double-checked and the types names are fine in translated
C file.
[...]
I think you ran into this
[issue](https://issues.dlang.org/show_bug.cgi?id=2
I am confused on how casting structs works. According to point 9
of https://dlang.org/spec/expression.html#CastExpression:
Casting a value v to a struct S, when value is not a struct of
the same type, is equivalent to:
```d
S(v)
```
However, the following program compiles and the resulting
to be distributing any consumer software.
Dave Chapman
r any guidance you can provide,
Dave Chapman
On Tuesday, 22 December 2020 at 21:37:23 UTC, Godnyx wrote:
On Tuesday, 22 December 2020 at 21:28:10 UTC, Dave P. wrote:
On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote:
[...]
Lol. Actually I just don't want to use Phobos and trying to
stay on core. Unfortunately, my var
On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote:
Is there a way? If not then how std.stdio does it?
I assume you’re asking this because you don’t have access to
std.stdio (such as using betterC).
The way to do it is to use the %.*s specifier in printf.
For example:
void print_st
On Tuesday, 22 December 2020 at 18:10:22 UTC, Dukc wrote:
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote:
[...]
Honestly, I just want all bits zero. I don’t work with any
platforms where null is not 0 and all-zero-bits aggregates can be
efficiently represented in static storage
On Friday, 18 December 2020 at 16:23:20 UTC, Adam D. Ruppe wrote:
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote:
Is the proper solution to change the struct definition to:
yeah that's the best option right now
A bit of a pain when porting, but alright.
I find the se
I got burned by behavior of struct initialization I didn’t
anticipate last night.
Consider a struct:
struct Foo {
float x, y, z;
int a, b, c;
}
My source C code was initializing it by doing something like:
Foo f = {.y = 3}
Which uses the C behavior that all the other fields will be s
On Thursday, 17 December 2020 at 21:24:40 UTC, FreeSlave wrote:
On Thursday, 17 December 2020 at 19:45:38 UTC, Dave P. wrote:
[...]
Something like that?
import std.stdio;
void print_int(alias n)()
{
writeln(n.stringof~"=", n);
}
void main()
{
int x = 42;
pr
In C, you can use a macro to get the source text of an expression
as a string. For example
#include
#define PRINT_INT(x) printf(#x " = %d\n", x)
int main(){
// prints "3 = 3"
PRINT_INT(3);
int x = 4;
// prints "x = 4"
PRINT_INT(x);
#define FOO 5
// prints "FOO = 5"
On Wednesday, 16 December 2020 at 06:46:42 UTC, Jacob Carlborg
wrote:
On Wednesday, 16 December 2020 at 04:17:13 UTC, Mike Parker
wrote:
However, the D calling convention is defined to be identical
to the C calling convention on the host system for everything
except Windows x86.
That's what
On Wednesday, 16 December 2020 at 03:50:07 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
[...]
Based on you requirement to use
On Wednesday, 16 December 2020 at 04:17:13 UTC, Mike Parker wrote:
On Tuesday, 15 December 2020 at 22:04:12 UTC, Dave P. wrote:
[...]
Mangling does not play any role in passing and calling function
pointers between D and C. It only plays a role in linking and
loading. You can declare
I can’t find this in the spec, but from experimentation it seems
like extern(C) only affects name mangling of functions at the top
level scope. Thus extern(C) function templates would be mangled
differently, but still use the C calling convention. Is this
right? I want to pass some templated f
On Tuesday, 15 December 2020 at 19:45:50 UTC, Q. Schroll wrote:
On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
Do I have to write both and have one forward
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
Do I have to write both and have one forward to the other for
more
complicated functions?
For free functions, yes.
Is there any way to write the function as a
If I define a method on a type, then I can call it both through a
pointer and
through a reference and the compiler does the right thing. Eg:
struct Foo {
int x;
void fooey(){
x++;
}
void report(){
printf("%d\n", x);
}
}
int main(){
Foo f;
f.fooey;
On Monday, 7 December 2020 at 17:07:20 UTC, Adam D. Ruppe wrote:
On Monday, 7 December 2020 at 17:01:45 UTC, Dave P. wrote:
Does `static` on a free function definition do anything?
Nope, D allows a lot of useless attributes so it doesn't
complain if you do certain things out of habit (
Does `static` on a free function definition do anything?
I know the meaning of it in C, but I can’t find an equivalent
definition (or
any definition of it at all) when applied to free functions in
the spec.
Are the two below any different or is it just for ease of porting
from C?
static i
Thanks for the thorough explanation. Most of that is how I was
thinking it worked. However, that leaves me perplexed. If
templates just generate code then how come:
Wouldnt..
class SomeClass(T) : ISomeInterface!T
and..
class SomeOtherClass(T) : ISomeInterface!T
...generate two diffe
I come from both a C++ and C# background. Those have been the
primary languages I have used. In C# you can do something like
this:
public interface ISomeInterface
{
T Value { get; }
}
public class SomeClass : ISomeInterface
{
T Value { get; set; }
}
On Thursday, 10 October 2019 at 15:56:36 UTC, Just Dave wrote:
I'm trying to get my head around mixing templates. I'm using it
as kind of a replacement for class inheritance as it seems to
fit better composition over inheritance. So I do something like:
mixin template Numb
On Thursday, 10 October 2019 at 15:53:20 UTC, Adam D. Ruppe wrote:
On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote:
if (obj is Person person)
Looks the same as D's
if(auto person = cast(Person) obj) {
// use person in here
} else {
// it was some other
I'm trying to get my head around mixing templates. I'm using it
as kind of a replacement for class inheritance as it seems to fit
better composition over inheritance. So I do something like:
mixin template NumberTemplate()
{
private:
int number = 0;
public:
int g
Even though static solutions would be more performance minded,
I'd actually prefer to see the runtime equivalent so I don't have
to rethink how I think as performance isn't really my major
concern right now.
In C# you can do something like:
if (obj is Person)
{
var person = obj as Person;
// do stuff with person...
}
where you can check the type of an object prior to casting. Does
D have a similar mechanism? It's so widely useful in the C# realm
that they even added sy
Thanks for the advice. I used a quick and dirty range solution as
was suggested. It allowed me to move on as I really wasn't
looking to fully implement a queue or stack. Just get something
that semantically behaved as such. I'll return later and optimize
it with the later suggestions if it's a
On Monday, 7 October 2019 at 17:24:19 UTC, Ferhat Kurtulmuş wrote:
On Monday, 7 October 2019 at 17:11:08 UTC, Just Dave wrote:
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a
On Monday, 7 October 2019 at 17:18:03 UTC, bachmeier wrote:
On Monday, 7 October 2019 at 17:11:08 UTC, Just Dave wrote:
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a stac
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a stack and queue, which I
think the dynamic array should be able to do (if I understand
correctly this is effectively the equivalent of
A machine reboot seems to have fixed the problem...
I downloaded it after experiencing debugging issues with
CodeBlocks (it wouldn't attach the provided debugger). I
downloaded Visual D and after some fiddling with Visual Studio
2019 not supporting third party templates in my version (had to
update it), I haven't been able to get Visual D to com
I was reading the C++ to D page, and came across this little bit
about when to call the base class constructor:
"It's superior to C++ in that the base constructor call can be
flexibly placed anywhere in the derived constructor."
Isn't there some inherent danger of not calling the base
constr
On Sunday, 29 September 2019 at 11:26:41 UTC, aberba wrote:
On Thursday, 26 September 2019 at 17:26:25 UTC, Dave Chapman
wrote:
[...]
your code... can you push it to GitHub so I can check it out?
I haven't used GitHub or git. Is there some other way?
On Thursday, 26 September 2019 at 00:10:40 UTC, aberba wrote:
On Wednesday, 25 September 2019 at 23:56:45 UTC, aberba wrote:
I'm looking for resources on using D for basic Raspberry Pi
programming...stuff like turning on and off an LED light. I
believe it requires being able to call the Raspber
Greetings,
This might be totally obvious, but I can't seem to figure out how
to specify an executable's name&path to be different for each
build types in my DUB package. For example, if my project is
named "dlang_test", I might want something like so:
dub build --build=debug
yields either
On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote:
On Sunday, June 10, 2018 23:59:17 Bauss via Digitalmars-d-learn
wrote:
What is the point of nothrow if it can only detect when
Exception is thrown and not when Error is thrown?
It seems like the attribute is useless because you c
On Sunday, 3 June 2018 at 21:32:06 UTC, gdelazzari wrote:
Note that this is not an attack to the language or anything (I
actually really love it), I'm just trying to understand the
reasoning behind this choice.
Because they have a thing about not adding new keywords,
apparently it's more im
On Sunday, 25 March 2018 at 12:23:03 UTC, kinke wrote:
On Sunday, 25 March 2018 at 10:58:37 UTC, Dave Jones wrote:
Is this stuff documented somewhere?
See
https://dlang.org/spec/abi.html#function_calling_conventions.
It defines the D calling convention for Win32 (int return value
in EAX
Given this...
int mulDiv64(int a, int b, int c)
{
asm
{
movEAX,a;
imul b;
idiv c;
}
}
which computes a*b/c, with the intermediate value in 64 bit. It
returns value that is left in EAX.
Is this stuff documented somewhere? I mean I found the page on
On Wednesday, 27 December 2017 at 14:14:42 UTC, Benjamin Thaut
wrote:
On Wednesday, 27 December 2017 at 13:40:28 UTC, rumbu wrote:
Is that normal?
It computes the difference between float.max and the next
smaller reprensentable number in floating point. The difference
printed by the program is
On Sunday, 26 November 2017 at 04:51:08 UTC, Adam D. Ruppe wrote:
On Sunday, 26 November 2017 at 01:35:01 UTC, Dave Jones wrote:
So it makes it a const/immutable/mutable method depending on
whether the instance it is called on is
const/immutable/mutable?
On the outside, yes.
So
On Saturday, 25 November 2017 at 21:59:54 UTC, Ali Çehreli wrote:
On 11/25/2017 01:51 PM, Dave Jones wrote:
> What does the "inout" after front() do here...
>
>
> @property ref inout(T) front() inout
> {
> assert(_data.refCountedStore.isInitialized);
&g
What does the "inout" after front() do here...
@property ref inout(T) front() inout
{
assert(_data.refCountedStore.isInitialized);
return _data._payload[0];
}
Cant seem to find an explanation in the docs or forums :(
On Friday, 24 November 2017 at 22:38:49 UTC, Jonathan M Davis
wrote:
On Friday, November 24, 2017 20:43:14 A Guy With a Question via
Digitalmars- d-learn wrote:
On Friday, 24 November 2017 at 14:43:24 UTC, Adam D. Ruppe
That requires data flow analysis, which the compiler doesn't do
a lot of, b
On Wednesday, 1 February 2017 at 21:43:09 UTC, Ali Çehreli wrote:
On 02/01/2017 01:34 PM, Dave Chapman wrote:
I am running an iMac with OS X 10.11.5 (El Capitan) and dmd
version 2.072.2
The following program prints out OS = win32.
Is this the intended behavior?
#!/usr/local/bin/rdmd
import
I am running an iMac with OS X 10.11.5 (El Capitan) and dmd
version 2.072.2
The following program prints out OS = win32.
Is this the intended behavior?
#!/usr/local/bin/rdmd
import std.stdio;
import std.system;
void main (string[] args) {
immutable OS os;
writefln("OS = %s",os);
}
On Sunday, 15 January 2017 at 03:43:32 UTC, Nestor wrote:
Hi,
I would simply like to get someone's age, but I am a little
lost with time and date functions. I can already get the
duration, but after reading the documentation it's unclear to
me how to convert that into years. See following cod
On Saturday, 14 January 2017 at 01:02:38 UTC, Ali Çehreli wrote:
On 01/13/2017 04:29 PM, Dave Chapman wrote:
> When I use auto and print out the type of b it is something
like
> args.main.FilterResult!(__lambda2, DirIterator).FilterResult
and for the
> "if"
I would like to do something like the code shown below but I
can't figure out how to do
it without loops inside the if statement.
When I use auto and print out the type of b it is something like
args.main.FilterResult!(__lambda2, DirIterator).FilterResult and
for the "if" version of
b and args.
t
is...
string cleanLine = strip( to!string(line) );
which should make a copy of the mutable buffer.
I still a beginner at D but I think that will fix your problem.
-Dave
When a program exits and D's memory management is cleaning up
calling all of the ~this's is there a reason it calls the outer
class's ~this before the inner class's ~this?
I was recently exploring the possibility of using
https://github.com/bheads/d-leveldb and the example in the readme
seg f
On Friday, 11 September 2015 at 19:34:46 UTC, Bahman Movaqar
wrote:
On Friday, 11 September 2015 at 16:33:52 UTC, Meta wrote:
The only ways to get implicit conversion between two types in
D are through `alias this`, inheritance, or implementing an
interface.
That's enough for me, I suppose.
I
On Wednesday, 11 March 2015 at 00:00:39 UTC, dnoob wrote:
Hello,
I am parsing some text and I have the following;
string text = "some very long text";
foreach(line; splitter(text, [13, 10]))
{
foreach(record; splitter(line, '*'))
{
foreach(field; splitter(record
You can create a static library from one or more .o files using
ar, if that helps (unless I've failed to understand the
question). "ar r libtest.a test.o" should do the job.
d
something obvious :)
/Dave
On 7/23/2010 5:14 AM, Steven Schveighoffer wrote:
On Fri, 23 Jul 2010 05:56:18 -0400, Dave
wrote:
On 7/22/2010 7:40 AM, Steven Schveighoffer wrote:
On Wed, 21 Jul 2010 22:27:10 -0400, awishformore
wrote:
On 22/07/2010 03:36, Sean Kelly wrote:
Make the ctors "shared static
On 7/22/2010 7:40 AM, Steven Schveighoffer wrote:
On Wed, 21 Jul 2010 22:27:10 -0400, awishformore
wrote:
On 22/07/2010 03:36, Sean Kelly wrote:
Make the ctors "shared static this()" -- those are only constructed
once when the process starts up. The non-shared static ctors are
thread-local.
On 7/21/2010 7:27 PM, awishformore wrote:
On 22/07/2010 03:36, Sean Kelly wrote:
Make the ctors "shared static this()" -- those are only constructed
once when the process starts up. The non-shared static ctors are
thread-local.
That concept is really weird, though. So this applies to anything
== Quote from torhu (n...@spam.invalid)'s article
> On 31.05.2010 22:27, dave wrote:
> > I'm trying to figure out if a dynamically allocated memory in D is getting
> > collected with this simple test (using tango):
> >
> > class Foo {
> >
I'm trying to figure out if a dynamically allocated memory in D is getting
collected with this simple test (using tango):
class Foo {
~this() {
// destructor
}
}
struct Item {
Foo a;
}
Item[] items;
items.length = 1;
items[0] = Item();
items[0].a = new Foo();
items = null;
Awesome! I just tried it out, the cast expression is exactly what I was looking
for.
I'm currently using Tango and tried out its runtime traits api, this works as
expected:
if(implements(typeof(something).classinfo, A.classinfo))
Thanks for the info!
Hi,
sort of new to D programming, coming from C++. Basically the question is if
there is some sort of a way to dynamically cast a variable in D much like you
do in C++?
ex:
interface A {...}
class B {...}
class C : B {...}
class D : B, A {...}
function(B something) {
A a = dynamic_cast(some
How to force one thread running on a single cpu in multi-cpu system but
without switching,just like the thread in windows iocp model.
70 matches
Mail list logo