How can I make executeShell ask for Admin Elevation?

2020-07-11 Thread Marcone via Digitalmars-d-learn
I don't want start program with admin elevation, but ask user for 
admin permission when some function is called.


Re: Calling a C function whose name is a D reserved word or keyword

2020-07-11 Thread Cecil Ward via Digitalmars-d-learn

On Monday, 6 July 2020 at 23:40:23 UTC, rikki cattermole wrote:

https://dlang.org/spec/pragma.html#mangle

pragma(mangle, "body")
extern(C) void body_func();


Thanks, that’s excellent


Re: GDC and DMD incompatability, can both be used?

2020-07-11 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 11 July 2020 at 04:28:32 UTC, cy wrote:
  125 | static foreach (string member; 
FieldNameTuple!T) {


The word "static" there can probably be removed and have it work 
exactly the same way. Worth a try.



Does gdc not support static foreach at all?


only the newest gdc does, version 10. version 9, in most package 
managers, doesn't include it.


but if it is inside a function, normal foreach does the same 
thing anyway.


Re: how to assign to shared obj.systime?

2020-07-11 Thread Arafel via Digitalmars-d-learn

On 10/7/20 20:30, mw wrote:

On Friday, 10 July 2020 at 17:35:56 UTC, Steven Schveighoffer wrote:
Mark your setTime as shared, then cast away shared (as you don't need 
atomics once it's locked), and assign:


synchronized setTime(ref SysTime t) shared {
    (cast()this).time = t;
}


I know I can make it work by casting, my question is:

we had a lock on the owning shared object already, WHY we still need the 
cast to make it compile.




Because the system don't know if just this lock is enough to protect 
this specific access. When you have multiple locks protecting multiple 
data, things can become messy.


What I really miss is some way of telling the compiler "OK, I know what 
I'm doing, I'm already in a critical section, and that all the 
synchronization issues have been already managed by me".


Within this block, shared would implicitly convert to non-shared, and 
the other way round, like this (in a more complex setup with a RWlock):


```
setTime(ref SysTime t) shared {
	synchronized(myRWMutex.writer) critical_section {  // From this point I 
can forget about shared

time = t;
}
}
```

As a workaround, I have implemented the following trivial helpers:

```
mixin template unshareThis() {
alias S = typeof(this);
static if (is(S C == shared C)) {}
static if (is(S == class) || is(S == interface)) {
C unshared = cast(C) this;
} else static if (is(S == struct)) {
C* unshared = cast(C*) 
} else {
static assert(0, "Only classes, interfaces and structs can be 
unshared");

}
}


pragma(inline, true);
ref unshare(S)(return ref S s) {
static if (is (S C == shared C)) { }
return *(cast(C*) );
}
```

With them you should be able to do either:

```
synchronized setTime(ref SysTime t) shared {
mixin unshareThis;
unshared.time = t;
}
```
(useful if you need multiple access), or:

```
synchronized setTime(ref SysTime t) shared {
time.unshare = t;
}
```


Re: Uploading coverage to Codecov doesn't work

2020-07-11 Thread Basile B. via Digitalmars-d-learn

On Wednesday, 8 July 2020 at 15:55:58 UTC, Mitacha wrote:

Hello there,

I've been trying to setup bitbucket pipelines to submit 
coverage to codecov, but with no luck.
I use `dub run -b unittest-cov` and it generates .lst files 
correctly, then `bash <(curl -s https://codecov.io/bash) -t 
$CODECOV_TOKEN` is called, but all I get is:


```
==> Bitbucket detected.
project root: .
Yaml not found, that's ok! Learn more at 
http://docs.codecov.io/docs/codecov-yaml

==> Running gcov in . (disable via -X gcov)
==> Python coveragepy not found
==> Searching for coverage reports in:
+ .
--> No coverage report found.
Please visit http://docs.codecov.io/docs/supported-languages
```
No reports were uploaded.

The thing I'm concerned about is "--> No coverage report 
found.". I checked and token is supplied. I ran same commands 
locally and get same result.


Is there some magic configuration in yaml file necessary, to 
make that work?


It's broken for me too, on gitlab,...

---
GitLab CI detected.
project root: .
--> token set from env
Yaml found at: ./.codecov.yml
==> Running gcov in . (disable via -X gcov)
==> Python coveragepy not found
==> Searching for coverage reports in:
+ .
--> No coverage report found.
Please visit http://docs.codecov.io/docs/supported-languages
---

That used to work perfectly. Note that it's broken for DMD test 
suite too.