On Friday, 29 December 2023 at 21:25:44 UTC, user1234 wrote:
[...]
Thanks, and the ideas are useful,
but please see below, suppose:
```
void main() {
size_t var1 = 1;
size_t var2 = 3;
size_t var3 = 5;
// ... Many other variables defined.
char[4] VarName;
// ...
// And some compl
Compile-time:
Is there a 'foo1' that yields 1 from the snippet below?
```
void main() {
import std.stdio;
size_t var1 = 1;
char[4] Txt = cast(char[4])("var1");
writeln(foo1(Txt));
}
```
Similarly, execution-time, is there a foo2 that wields 2 from the
snippet below:
```
void mai
On Thursday, 21 December 2023 at 10:38:16 UTC, DLearner wrote:
[...]
And now, returning to the problem after several hours Christmas
shopping, everything seems to work perfectly!
This applies to dmd version v2.106.0-dirty under Windows.
Module containing several functions with unittests, no 'main'
function.
Was testing ok some time ago, producing '1/1 modules PASSED
unittests' message.
Today,
```
dmd -main -unittest -run
```
produced nothing, just a return to the com
The code below fails to compile with
Error: function `test1.foo` no `return exp;` or `assert(0);` at
end of function
unless the commented-out assert(0) is included.
Please, what rule of D is being broken?
foo does not unconditionally loop, and the only places where foo
returns, it returns wit
On Sunday, 26 November 2023 at 15:35:39 UTC, Adam D Ruppe wrote:
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote:
string mxnTest(string strVar1, string strVar2) {
return `(int Var1, int Var2) {
if (Var1 > Var2) {
return true;
} else {
return false;
The two little demo scripts:
```
string mxnAdd()(string strName) {
return `(typeof(` ~ strName ~ `) Pld) {
import core.stdc.stdlib : malloc;
struct Mst {
typeof(` ~ strName ~ `) Pld;
int I1;
}
Mst*MstPtr;
MstPtr = cast(Mst*)(malloc(Mst.s
On Tuesday, 5 December 2023 at 00:31:35 UTC, H. S. Teoh wrote:
On Mon, Dec 04, 2023 at 11:46:45PM +, DLearner via
Digitalmars-d-learn wrote: [...]
Basically, B corresponds to the whole record (and only a whole
record
can be read).
But the task only requires Var1 and Var2, the last two
On Monday, 4 December 2023 at 23:16:27 UTC, thinkunix wrote:
DLearner via Digitalmars-d-learn wrote:
On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote:
[...]
Is something like this what you had in mind?
```
void main() {
import std.stdio;
mixin template A() {
int I1
On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote:
[...]
Is something like this what you had in mind?
```
void main() {
import std.stdio;
mixin template A() {
int I1;
int I2;
char X;
}
struct B {
mixin A;
int Var1;
int Var2;
}
Suppose we need a construct like:
```
void main() {
struct A {
int I1;
int I2;
char X;
}
struct B {
A Dummy;
int Var1;
int Var2;
}
}
```
But do not want to give an explicit name (like 'Dummy' above) to
the A struct held within the B struct.
Just
The code:
```
void main() {
struct SB {
char SBChrFld1;
char SBChrFld2;
int SBIntFld1;
int SBIntFld2;
}
SB SBVar;
SB* wkSBPtr;
void* StartPtr1 = null;
mixin(mxnDelMbr("StartPtr1", "wkSBPtr"));
return;
}
string mxnDelMbr()(string strStartPt
On Tuesday, 28 November 2023 at 18:43:37 UTC, Adam D Ruppe wrote:
On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote:
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A,
from A_Ptr of type A*.
I think what you really want is
typeof(*A_Pt
Trying to manipulate 'typeof' return strings, preferably at
compile-time.
e.g. to produce struct B below (intended to have an A
sub-struct), from A_Ptr alone.
```
struct A {
int AFld1;
}
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from
A_
On Thursday, 23 November 2023 at 17:02:58 UTC, Paul Backus wrote:
[...]
This is a known limitation:
https://issues.dlang.org/show_bug.cgi?id=23637
[...]
Sorry to come back to this, but the reference above suggests
_not_ a bug in the compiler.
If not a bug in the compiler, please, what is g
On Thursday, 23 November 2023 at 18:54:09 UTC, Julian Fondren
wrote:
[...]
The `enum` answer?
[...]
No, the 'template' answer.
To me, if the 'template' suggestion worked (as it did), then my
simple mixin (as in my original post) should also work.
On Thursday, 23 November 2023 at 17:03:29 UTC, Julian Fondren
wrote:
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote:
Why is this so, bearing in mind the concatenations are
executed at
compile, not run, time?
If you compile without -betterC, it'll work, but if you examine
the r
Code below is intended to test simple mixin with lambda function
under -betterC.
Works with full-D, but fails with 'needs GC' errors under
-betterC.
Why is this so, bearing in mind the concatenations are executed at
compile, not run, time?
```
// Test harness
extern(C) void main() {
i
On Wednesday, 22 November 2023 at 16:51:54 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 23/11/2023 5:34 AM, DLearner wrote:
Is the encapsulation issue resolved if the struct itself is
held in another module, and imported from that module into
both the 'main' and 'Ex_mod' files?
Each modul
On Wednesday, 22 November 2023 at 16:11:03 UTC, Richard (Rikki)
Andrew Cattermole wrote:
You have two ``SA`` structs, each in different encapsulations.
Each of them are different, even if they have similar members.
In D types that look the same do not combine, they are distinct.
You can see th
Please,
Why does:
```
// Test module Ex_mod
struct SA {
int SAIntFld1;
int SAIntFld2;
}
bool AddEle(ref void* StartPtr, SA PayLoad1) {
import core.stdc.stdlib : malloc;
struct Ele {
SA PayLoad;
Ele* EleNxtPtr;
Ele* ElePrvPtr;
}
Ele*ElePtr;
Ele*
On Friday, 23 June 2023 at 16:51:16 UTC, Ali Çehreli wrote:
On 6/23/23 07:22, DLearner wrote:
>`} else static if (__traits(isPOD, typeof(` ~ VarName
~ `))) {` ~
Regardless, you can also use the 'is' expression with the
'struct' keyword. If T is a struct,
is (T == struct)
that will
On Friday, 23 June 2023 at 15:48:44 UTC, H. S. Teoh wrote:
On Friday, 23 June 2023 at 15:22:36 UTC, DLearner wrote:
On Friday, 23 June 2023 at 14:31:45 UTC, FeepingCreature wrote:
On Friday, 23 June 2023 at 14:22:24 UTC, DLearner wrote:
[...]
```
static assert(__traits(isPOD, int)); // ok.
s
On Friday, 23 June 2023 at 14:31:45 UTC, FeepingCreature wrote:
On Friday, 23 June 2023 at 14:22:24 UTC, DLearner wrote:
[...]
```
static assert(__traits(isPOD, int)); // ok.
static assert(__traits(isPOD, byte)); // ok.
```
It's a bug in either the spec or the compiler.
I am using
```
DMD64
Hi
Was looking for compile-time detection of a struct variable.
However, the following test code gave the two 'FAILS' shown below.
Comments?
```
void main() {
import std.stdio : writeln;
import std.traits;
string mxnTst(string VarName) {
return
`static if (is(typeof(` ~ Var
On Sunday, 11 June 2023 at 21:32:11 UTC, Andy wrote:
[...]
void main() {
import std.stdio;
struct foo {}
foo* fooptr;
static if (is(typeof(fooptr) == T*, T))
writeln("fooptr is a pointer to a ", T.stringof);
else
writeln(
Only a small thing, but is it intended that:
```
void main() {
// static assert (false, "Static Assert triggered");
assert(false, "Assert triggered");
}
```
produces
```
core.exception.AssertError@staticassertex01.d(4): Assert triggered
```
but removing the // produces
```
staticassertex01.d(
Please consider:
```
void main() {
import std.stdio;
struct foo {
int foo1;
char foo2;
}
foo* fooptr;
void* genptr;
static if (is(typeof(fooptr) == void*))
writeln("fooptr is void*");
else
writeln("fooptr is not void*");
On Monday, 5 June 2023 at 18:22:45 UTC, Ernesto Castellotti wrote:
[...]
It's not so easy to deal automatically in case of multiple
modules
_multiple modules_
The following code, in a batch (.bat) file, works for me:
```
@echo off
:loop
if [%1]==[] goto loopexit
type .\%1.d > .\__temp_%1.d
ech
On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote:
[...]
The docs say it should work:
https://dlang.org/spec/betterc.html#unittests
[...]
Thank you for the link, can confirm that:
```
int foo() {
return 4;
}
unittest {
assert(foo() != 4, "!= Assert triggered.");
assert(fo
On Monday, 5 June 2023 at 03:42:20 UTC, ryuukk_ wrote:
[...]
I don't know how all this works, ...
For what it is worth, running _both_ the above code fragments
with:
```
dmd -main -unittest -i -run foo
```
(ie removing the -betterC flag)
produces:
```
foo.d(8): [unittest] != Assert triggere
Neither:
```
extern(C) int foo() {
return 4;
}
unittest {
assert(foo() != 4, "!= Assert triggered.");
assert(foo() == 4, "== Assert triggered.");
}
```
Nor:
```
int foo() {
return 4;
}
unittest {
assert(foo() != 4, "!= Assert triggered.");
assert(foo() == 4, "== Assert tr
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
void main() {
import std.stdio : writeln;
S1 Var1 = S1(1, 2);
writeln("Total Var1 = ", Var1.foo());
S2 Var2 = S2(1,
On Wednesday, 19 April 2023 at 14:42:44 UTC, bachmeier wrote:
[...]
My understanding (from my occasional use of Windows) is that
DMD installs the Community Edition of Visual Studio. That
should solve your original issue, and you shouldn't need to
mess with sppn.exe.
Well it took a little whil
On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 20/04/2023 12:07 AM, DLearner wrote:
Error: C preprocess command sppn.exe failed for file ex01.c,
exit status 1
Did you verify that sppn is accessible in that shell?
As in run it, can it be found?
If not
On Wednesday, 19 April 2023 at 11:50:28 UTC, bachmeier wrote:
[...]
Did you use the switch `-m32omf`?
https://dlang.org/spec/importc.html#auto-cpp
No so following the references I tried every preprocessor option
I could find:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -m32omf
f
C source ex01.c:
```
#include
int main()
{
printf("hello world\n");
return 0;
}
```
'dmc ex01.c' produces message:
```
link ex01,,,user32+kernel32/noi;
```
but does generate .obj, .map and .exe files,
and the exe executes properly.
However, trying to use ImportC via 'dmd ex01.c' produces
On Tuesday, 18 April 2023 at 21:31:21 UTC, thinkunix wrote:
[...]
If not calling C code, why use extern(C) for D code?
Wanted to test out options of calling D routine (possibly
-betterC) from both C and (full) D.
On Tuesday, 18 April 2023 at 20:00:18 UTC, ag0aep6g wrote:
On Tuesday, 18 April 2023 at 19:49:04 UTC, DLearner wrote:
```
void main() {
import std.stdio;
extern(C) void ExtCallee();
```
Move that declaration out of main.
Thanks - worked!
Is the declaration inside main not visible to t
Wanted to try out linking two source files independantly compiled.
ExtCallee.d source file:
```
extern(C) void ExtCallee() {
import std.stdio;
writeln("Entered: ", __FUNCTION__);
writeln("Exiting: ", __FUNCTION__);
}
```
ExtMain.d source file:
```
void main() {
import std.stdio;
e
Requirement is to write some D code (which avoids the GC), that
will be called from C.
So simple approach seemed to be to write D code under -betterC
restrictions.
However, also need variable length arrays - but D Dynamic Arrays
not allowed under -betterC.
So tried trivial example using std.c
Is it correct that this _single_ keyword is used to indicate
_two_ quite different things:
1. As a shorthand to make the type of the variable being declared
the same as the type on the right hand side of an initial
assignment.
Example: ```auto A = 5;``` makes A an int.
2. To indicate storag
Hi
Please consider (1):
```
void main() {
import std.stdio;
int wk_Idx;
int[2] IntArr;
IntArr[0] = 1;
IntArr[1] = 2;
for (wk_Idx = 0; wk_Idx <= 1; wk_Idx = wk_Idx + 1) {
writeln("wk_Idx = ", wk_Idx, " IntArr = ", IntArr[wk_Idx]);
}
}
```
Now consider (2), which is
On Wednesday, 18 January 2023 at 14:18:58 UTC, Salih Dincer wrote:
On Wednesday, 18 January 2023 at 13:45:04 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC
feature. cl.exe seems to be the compiler
On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC feature.
cl.exe seems to be the compiler. I think it is the compiler.
Can you run that program from the command line?
Fails with:
```
C:\Users\SoftDev>c1.exe
'c1.exe'
On Tuesday, 17 January 2023 at 19:17:31 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 17:36:41 UTC, ryuukk_ wrote:
On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:
[...]
Downloaded latest dmd for windows from web
On Tuesday, 17 January 2023 at 17:36:41 UTC, ryuukk_ wrote:
On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:
On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 11:21:08 UTC, Denni
On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:
On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:
On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd e
On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:
On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not
supported
ex01.c(1): Error: no type for declarator befor
This relates to the first example under 41.1 Quick Examples.
Stored as ex01.c, run as shown.
```
#include
int main()
{
printf("hello world\n");
return 0;
}
```
Produced:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is no
If unittest run without a main() being present, crashes on link
error:
```
lld-link: error: subsystem must be defined
Error: linker exited with status 1
```
Is this intended?
It's not a problem to add temporary
```
void main() {
}
```
to the bottom of the module, but seems wrong as not then te
On Sunday, 8 January 2023 at 23:59:21 UTC, ryuukk_ wrote:
[...]
Example_03:
```
void main() {
import core.stdc.stdio : printf;
int[] A;
printf("Hello betterC\n");
}
```
```
dmd -betterC -run Example_03
```
Expected result: Failure at compilation stage, owing to
presence of dynamic arr
I thought dynamic arrays were unavailable under -betterC.
Example_02:
```
extern(C) void main() {
import core.stdc.stdio : printf;
int[] A;
printf("Hello betterC\n");
}
```
```
dmd -betterC -run Example_02
```
Expected result: Failure at compilation stage, owing to presence
of dynamic
On Thursday, 5 January 2023 at 19:54:01 UTC, H. S. Teoh wrote:
On Thu, Jan 05, 2023 at 07:49:38PM +, DLearner via
Digitalmars-d-learn wrote:
Suppose there is a D main program (not marked anywhere with
@nogc),
that _both_
A: Calls one or more C functions that themselves call
malloc/free
Suppose there is a D main program (not marked anywhere with
@nogc), that _both_
A: Calls one or more C functions that themselves call
malloc/free; and also
B: Calls one or more D functions that themselves call malloc/free
via `import core.stdc.stdlib;`
Assuming the malloc/free's are used cor
On Wednesday, 30 November 2022 at 02:29:03 UTC, Paul Backus wrote:
[...]
If you want a dynamic array with value semantics, you should
use a library-defined container type (e.g., `struct
DynamicArray`).
I agree should not change existing meaning of
```
int[] A;
```
But why not allow a const
On Tuesday, 29 November 2022 at 19:06:20 UTC, rikki cattermole
wrote:
[...]
Please see the following example:
```
void main() {
import std.stdio;
int[] VarArr1, VarArr2;
VarArr1.length = 6;
VarArr1[5] = 10;
VarArr1[4] = 9;
VarArr1[3] = 8;
VarArr1[2] = 7;
VarArr1[1] = 6
To me, it appears that there are really two (_entirely separate_)
concepts:
A. Supporting the useful concept of variable length (but
otherwise entirely conventional) arrays;
B. Supporting a language feature that acts as a window to an
array, through which that array can be manipulated.
And c
On Sunday, 13 November 2022 at 16:11:17 UTC, matheus. wrote:
[...]
You should add the code below after "auto B = A.dup;":
B[0].Txt = A[0].Txt.dup;
The "Txt" property inside B is still referencing A without the
above.
Matheus.
Thank you - your suggestion worked.
The slight generalisati
On Sunday, 13 November 2022 at 14:39:26 UTC, Siarhei Siamashka
wrote:
On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote:
Creating a step 1.5:
```
int[] B = A;
```
```D
auto B = A.dup;
```
This will create a copy of A rather than referencing to the
same buffer in memory.
Tested:
Hi
Program has two steps:
1. Creates an array (int[] A), whose size and element values are
only known at run-time.
Then:
2. The elements (but not the array size) are further processed in
a way that may or may not alter their value.
Requirement: to identify the indices (if any) of the elemen
On Friday, 28 October 2022 at 21:32:46 UTC, rikki cattermole
wrote:
On 29/10/2022 4:15 AM, DLearner wrote:
However, going forward, I don't want copies of OM anywhere
other than UD.
If you want your own private library on your system (that will
get used a lot), you can create a package and use
On Friday, 28 October 2022 at 11:35:44 UTC, Adam D Ruppe wrote:
On Wednesday, 26 October 2022 at 16:20:01 UTC, DLearner wrote:
Wanted to use a function stored in a module outside the main
source.
easiest thing to do with dub is to add it as a sourcePath or a
sourceFile. Well, actually, easies
On Thursday, 27 October 2022 at 00:35:26 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 22:51:53 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 18:53:58 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
[...]
The linker failed to resolve because
On Wednesday, 26 October 2022 at 18:53:58 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh
wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
[...]
Maybe try
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
Hi
Never used DUB before.
Wanted to use a function stored in a module outside the main
source.
Main source has `import ;`
Put a line into the
On Saturday, 16 October 2021 at 19:29:59 UTC, Dennis wrote:
On Saturday, 16 October 2021 at 19:28:04 UTC, DLearner wrote:
How does one obtain from strVar:
1. The type of fooVar;
`typeof(mixin(strVar))`
2. The value of fooVar?
`mixin(strVar)`
```
void main() {
import std.stdio;
int
Hi
Suppose string variable strVar has value "fooVar".
fooVar is a valid variable name used elsewhere in the program.
How does one obtain from strVar:
1. The type of fooVar;
2. The value of fooVar?
Best regards
Thanks for the responses.
Please confirm that if the addition of two uint variables
produces a result larger than can be held in a uint:
1. This is a D-legal operation (however inadvisable!), with the
D-defined result of wraparound;
2. Emphasing 1. above: the result is not undefined, or an error
(by the rules of D), or
On Thursday, 2 September 2021 at 23:12:28 UTC, Steven
Schveighoffer wrote:
[...]
immutable means "I can never change and *everything I point at*
can never change".
[...]
If that is how the language defines the keyword 'immutable' when
used in the definition of a pointer variable, then so be
On Thursday, 2 September 2021 at 16:46:46 UTC, Steven
Schveighoffer wrote:
On 9/2/21 12:01 PM, DLearner wrote:
Suppose there is a variable that is set once per run, and is
(supposed) never to be altered again. However, the value to
which it is set is not known at compile time.
Example below,
Suppose there is a variable that is set once per run, and is
(supposed) never to be altered again. However, the value to
which it is set is not known at compile time.
Example below, variable is 'ArrPtr';
```
ubyte[10] Arr;
// immutable void* ArrPtr;
void* ArrPtr;
void main() {
ArrPtr = ca
On Thursday, 26 August 2021 at 16:28:22 UTC, Adam D Ruppe wrote:
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote:
Please confirm that mixins of format:
You really shouldn't use string mixins like this at all. If you
want to work with a variable, pass the variable itself as an
arg
On Thursday, 26 August 2021 at 16:28:22 UTC, Adam D Ruppe wrote:
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote:
Please confirm that mixins of format:
You really shouldn't use string mixins like this at all. If you
want to work with a variable, pass the variable itself as an
arg
Please confirm that mixins of format:
```
string mxn1(string VarName) {
...
}
```
Invoked like:
```
mixin(mxn1("Var1"));
```
Have a wider scope than mixins like:
```
string mxn2(string VarName)() {
...
}
```
Invoked like:
```
mixin(mxn2!"Var2");
```
I tried direct replacement of former by
On Wednesday, 25 August 2021 at 22:57:23 UTC, jfondren wrote:
Contrast:
[...]
```d
void main() {
import std.stdio;
uint TestVar = 5;
string mxnWrite_Size_t(string VarName)() {
static if (typeof(mixin(VarName)).stringof == "uint") {
return `write("` ~ VarName ~ `");
On Wednesday, 25 August 2021 at 22:33:00 UTC, H. S. Teoh wrote:
[...}
I think what you meant to write is:
static if (typeof(mixin(VarName)).stringof == "uint") {
You want the type of the variable named by VarName, not the
type of VarName.
T
I understand your reasoning, but:
```
v
Please see below:
```
void main() {
import std.stdio;
uint TestVar = 5;
string mxnWrite_Size_t(string VarName) {
static if (typeof(VarName).stringof == "uint") {
return `write("` ~ VarName ~ `");`;
} else {
return `writeln("Apparently TestVar not a uint"
Hi
The code below compiles and runs producing 'Not null'.
```
void main()
{
import std.stdio;
int Var1;
int* ptrVar;
ptrVar = &Var1;
if (ptrVar == null) {
writeln("Null");
} else {
writeln("Not null");
}
}
```
However, should it not fail to compile, as '=
Hi
Please see code below:
```
void main() {
import std.stdio;
size_t i;
size_t j;
i = 5;
writeln("i = ",i);
}
```
Is there a compiler option that would warn that variable 'j' is
defined but not used?
Best regards
Hi
This may be due to Windows, not DMD.
Please see code below (held in test.d):
```
void main() {
import std.stdio;
writeln("Test");
assert(false, "TestAssert");
}
```
`
dmd -i -run test.d
`
results in both "Test" and the "TestAssert" string (and trace)
being routed to screen.
But
On Sunday, 11 July 2021 at 12:47:48 UTC, Adam D Ruppe wrote:
On Sunday, 11 July 2021 at 12:37:20 UTC, DLearner wrote:
C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>type k_mod.d
// k_mod.d
ubyte[MemSiz] MemPool;
You didn't import the other module here.
D's imports aren't like C's inclu
On Sunday, 11 July 2021 at 12:01:27 UTC, jfondren wrote:
On Sunday, 11 July 2021 at 10:58:58 UTC, DLearner wrote:
Is there a way of forcing DMD to extend the scope of `MemSiz`
to include `k_mod`?
Best regards
```
$ cat k_mod.d
import test01;
ubyte[MemSiz] MemPool;
$ cat test01.d
enum MemSi
Please see the two code snippets below:
```
// test01.d
enum MemSiz = 240;
void main() {
import k_mod;
}
```
and
```
// k_mod.d
ubyte[MemSiz] MemPool;
```
A number of tests need to be run on code in `k_mod`,
with different sizes of the static array `MemPool` in each test.
So each test
Hi
Please confirm that:
`
assert(false, __FUNCTION__ ~ "This is an error message");
`
Will _not_ trigger GC issues, as the text is entirely known at
compile time.
Best regards
On Saturday, 15 May 2021 at 11:38:22 UTC, Adam D. Ruppe wrote>
Just use
```
dmd -i main.d
instead. It will be about 2x faster and more reliable.
```
Your suggestion worked.
Thank you.
On Saturday, 15 May 2021 at 07:19:08 UTC, Mike Parker wrote:
Then it must be an issue with rdmd...
rdmd build 20210311
Running under Win-10.
On Saturday, 15 May 2021 at 07:05:00 UTC, Mike Parker wrote:
That's odd. What's your command line?
rdmd main.d
```
// main
void main() {
import A;
// import B;
import std.stdio;
writeln("Entered main");
fnA1();
writeln("Leaving main");
}
```
```
module A;
void fnA1() {
import B;
import std.stdio;
writeln("Entered fnA1");
fnB1();
writeln("Leaving fnA1");
}
```
```
modul
I am getting 'Error 42: Symbol Undefined' while testing some
(fairly) complex imports.
There was a reference in January to an Optlink bug that seemed
like it could be responsible.
If rdmd can use another linker (and one was recommended), I might
be able to test things further.
Best regards
>>>
void foo(pint p1) {
alias pint=uint;
import std.stdio;
writeln("p1 = ", p1);
}
void main() {
alias pint=uint;
pint var1;
var1 = 7;
foo(var1);
}
<<<
Does not compile.
But the rather similar:
alias pint=uint;
void fo
Hi
Is there any limitation as to the number of pointer indirections?
I have a construct:
a.b.c.d = x;
where all the variables are pointers to struct (the same struct).
This fails with 'Access Violation',
but if I change the code to:
temp = a.b.c;
temp.d = x;
everything seems to work.
Be
On Saturday, 3 April 2021 at 13:50:27 UTC, ag0aep6g wrote:
On 03.04.21 15:34, DLearner wrote:
The following produces the expected result.
However, changing extern(C) to extern(D) causes linker
failures.
To me, that is bizarre.
Testmain:
extern(C) int xvar;
[...]
Testmod:
extern extern(C) in
On Saturday, 3 April 2021 at 13:38:25 UTC, rikki cattermole wrote:
On 04/04/2021 2:34 AM, DLearner wrote:
However, changing extern(C) to extern(D) causes linker
failures.
To me, that is bizarre.
extern(D) sets the ABI AND mangling.
D mangling incorporates things like the module name.
I'm
The __gshared is irrelevant to it working between modules, but
it is relevant if you want C compatibility between threads
(NOTE: extern(C) sets mangling, otherwise the module would be
encoded in its name).
Solved:
The following produces the expected result.
However, changing extern(C) to extern
https://dlang.org/spec/attribute.html#gshared
However, you should be using the module system for accessing
globals, rather than redeclaring them.
If the module system is dumped, and evrything put into one file,
works perfectly.
With or without __gshared in from of 'int xvar'.
int xvar;
void
extern(L) extern otherQualifiersIfAny variableType
variableName; //appears to be a variable declared outside of
the module, so at link time a .obj file will have to declare a
variable with this symbol name or else the linker will error
out.
```
It seems that case 4 is what you desired but i do
Tried the following, same result (1,0,2,1):
testmain:
__gshared int xvar;
import testmod;
void main() {
import std.stdio;
writeln("Entering: main");
xvar = 1;
writeln("xvar=", xvar);
testsub();
writeln("xvar=", xvar);
writeln("Leaving: main");
}
testmod:
void testsub() {
On Saturday, 3 April 2021 at 10:05:45 UTC, rikki cattermole wrote:
On 03/04/2021 11:01 PM, DLearner wrote:
[...]
TLS variable with D mangling, not a c global.
[...]
That is a regular variable.
Setting the calling convention/mangling like that doesn't make
any sense and shouldn't be allow
1 - 100 of 137 matches
Mail list logo