Here I am having a problem with templates again. No matter how
much I read, I can't seem to understand how templates/mixins
work. So I'm having the following code (just a snippet of the
real code):
```
if (c != '%') {
if (stdout_index < STDOUT_BUF_LEN) {
stdout_buffer[stdout_
On Sunday, 19 December 2021 at 23:21:00 UTC, Stanislav Blinov
wrote:
On Sunday, 19 December 2021 at 22:29:21 UTC, vit wrote:
Hello,
Why is copy ctor in this example not called?
Because D runtime isn't properly married to copy constructors
yet. I.e. it's a bug, a variant of this one:
https://
On Monday, 20 December 2021 at 08:45:50 UTC, rempas wrote:
Here I am having a problem with templates again. No matter how
much I read, I can't seem to understand how templates/mixins
work.
So any ideas why this doesn't work?
because you cannot have statements directly in a template (the
fac
I have a small struct that I'm trying to interface to.
C++
```cpp
struct __declspec(dllexport) SmallStruct
{
float value = 0;
//float value2 = 0;
//float value3 = 0;
SmallStruct(float val)
: value(val)
{
}
static SmallStruct GetValue(float input)
{
return SmallStruct(inp
On Monday, 20 December 2021 at 09:30:30 UTC, rumbu wrote:
because you cannot have statements directly in a template (the
fact that is a mixin template is irelevant), only declarations.
If you want to just insert some random code, use strings. You
can create a templated enum to store your par
On Monday, 20 December 2021 at 10:49:20 UTC, rempas wrote:
On Monday, 20 December 2021 at 09:30:30 UTC, rumbu wrote:
Thanks a lot for the info. When I try to use this code, I'm
getting the following error:
```
Error: expression expected, not `%`
Error: expression expected, not `%`
```
My fa
On Monday, 20 December 2021 at 10:24:00 UTC, Jan wrote:
Is this a known issue, or is there a way to instruct DMD to use
a specific calling convention for a given type?
This looks like a bug. It seems to work without constructor in
C++, but still crashes with a constructor in D. It also seems t
On Monday, 20 December 2021 at 11:30:09 UTC, rumbu wrote:
On Monday, 20 December 2021 at 10:49:20 UTC, rempas wrote:
On Monday, 20 December 2021 at 09:30:30 UTC, rumbu wrote:
Thanks a lot for the info. When I try to use this code, I'm
getting the following error:
```
Error: expression expect
On Monday, 20 December 2021 at 11:58:03 UTC, Tim wrote:
On Monday, 20 December 2021 at 10:24:00 UTC, Jan wrote:
Is this a known issue, or is there a way to instruct DMD to
use a specific calling convention for a given type?
This looks like a bug. It seems to work without constructor in
C++, b
On Monday, 20 December 2021 at 11:30:09 UTC, rumbu wrote:
Enums (that's why the string is declarated as enum) are
evaluated at compile time, the concatenation op will not end in
your code as instruction, so you can do anything outside
betterC rules as long you do it at compile time. You are j
On Monday, 20 December 2021 at 11:58:58 UTC, Tejas wrote:
Ehh, it still fails; should've explicitly put the length of the
array and the `extern (C)` in `main`
```d
module demo;
[ ... ]
extern(C) /+added this because you used -betterC+/ void main() {
while (true) {
mixin
On Monday, 20 December 2021 at 18:03:09 UTC, rempas wrote:
> Now the problem is that I want it to get the name of so
> symbol and add it to a string literal.
Let's check this example: enum state(alias name) = `name` ~ ` =
10;`;
https://dlang.org/spec/traits.html#identifier
On Monday, 20 December 2021 at 18:06:32 UTC, rempas wrote:
On Monday, 20 December 2021 at 11:58:58 UTC, Tejas wrote:
Ehh, it still fails; should've explicitly put the length of
the array and the `extern (C)` in `main`
```d
module demo;
[ ... ]
extern(C) /+added this because you used -bette
On Monday, 20 December 2021 at 18:12:35 UTC, Stanislav Blinov
wrote:
https://dlang.org/spec/traits.html#identifier
Thanks!!! Finally I was able to do it! The code is the following
(well not in my final project but it's a demonstration):
```
enum add_char(string c) =
`if (stdout_index < ST
On Monday, 20 December 2021 at 18:23:44 UTC, rempas wrote:
On Monday, 20 December 2021 at 18:12:35 UTC, Stanislav Blinov
wrote:
https://dlang.org/spec/traits.html#identifier
Thanks!!! Finally I was able to do it! The code is the
following (well not in my final project but it's a
demonstrati
On Monday, 20 December 2021 at 11:58:03 UTC, Tim wrote:
On Monday, 20 December 2021 at 10:24:00 UTC, Jan wrote:
Is this a known issue, or is there a way to instruct DMD to
use a specific calling convention for a given type?
This looks like a bug. It seems to work without constructor in
C++, b
On Monday, 20 December 2021 at 18:58:39 UTC, bachmeier wrote:
You can see the ["String mixins" section
here](http://ddili.org/ders/d.en/mixin.html) for more details.
Mixins are generated at compile time, so if you're referring to
a string mixin inside a runtime loop, the code will not be
gen
On Sunday, 19 December 2021 at 09:49:29 UTC, eugene wrote:
test program:
```d
import std.stdio;
import core.sys.freebsd.config;
import core.sys.freebsd.sys.event;
void main(string[] args) {
writefln("FreeBSD_version = %s", __FreeBSD_version);
writefln("sizeof(kevent_t) = %s", kevent_t.s
I'm trying to implement "printf" and I'm getting an error. The
smallest possible code to demonstrate the error is:
```
import core.stdc.stdio;
void print(T...)(string prompt, T args) {
// Suppose all 'args' are of type "string" for this example
ulong carg = 0;
for (ulong i = 0; i < args[c
On Monday, 20 December 2021 at 21:26:45 UTC, rempas wrote:
// Suppose all 'args' are of type "string" for this example
still use
foreach(arg; args)
and skip that index variable.
Here how i'd do, but i'm not sure how to keep track of the index
of the arguments, i forgot..
```D
import core.stdc.stdio: putc, stdout;
void print(T...)(string prompt, T args)
{
foreach (a; args)
{
alias A = typeof(a);
static if (is(A : string))
{
f
Here's this function, which serves as a thread entry point:
https://github.com/ZILtoid1991/iota/blob/main/source/iota/audio/wasapi.d#L220
The problem is, that even with disabling all error-handling that
would allow to shut down the thread safely, the thread only runs
that while loop once.
Ho
On 12/20/21 3:56 PM, solidstate1991 wrote:
> The problem is, that even with disabling all error-handling that would
> allow to shut down the thread safely, the thread only runs that while
> loop once.
I bet it's throwing an Error. Call your thread entry function from a
try-catch wrapping functi
On Monday, 20 December 2021 at 21:49:59 UTC, Adam D Ruppe wrote:
still use
foreach(arg; args)
and skip that index variable.
I know I can use foreach ("static foreach" more specifically) but
I need to be able to get the index to choose a specific argument
because I want to do formatting (th
On Monday, 20 December 2021 at 22:02:02 UTC, russhy wrote:
Here how i'd do, but i'm not sure how to keep track of the
index of the arguments, i forgot..
```D
import core.stdc.stdio: putc, stdout;
void print(T...)(string prompt, T args)
{
foreach (a; args)
{
alias A = typeof(a);
On Tuesday, 21 December 2021 at 01:13:10 UTC, Ali Çehreli wrote:
Note: nothrow means "does not throw Exception". Errors can
still be thrown.
Ali
Which sort of makes sense since they're in theory
"unrecoverable", but the name is sort of misleading because of
this minor detail. It should at
On Monday, 20 December 2021 at 21:19:43 UTC, rempas wrote:
I don't have FreeBSD and I can't check the output and header
I have it VirtualBox
files myself but from what you are saying this seems to me as a
bug. I would recommend you to file an
[issue](https://issues.dlang.org/) just so the de
27 matches
Mail list logo