Re: String switch is odd using betterC

2020-02-26 Thread Abby via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: Any idea why? Ok so this is enough to produce the same result, it seems that there is a problem in string switch when there is more the 6 cases. extern(C) void main() { auto s = "F"; final switch(s) { case "A":

String switch is odd using betterC

2020-02-26 Thread Abby via Digitalmars-d-learn
I have a simple enum of strings like so: enum Alphabet : string { a = "A", b = "B", c = "C", d = "D", e = "E", f = "F", g = "G" } and then simple final switch like so: extern(C) void main() { auto s = Alphabet.f; final switch(s) { case

Re: String switch is odd using betterC

2020-02-26 Thread Abby via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2999): Error: TypeInfo cannot be used with -betterC Odd think is that wehen I remove g from my enum it compiles just fine, so it seems that this compilation error occurs only

Re: betterC CTFE nested switch

2020-02-18 Thread Abby via Digitalmars-d-learn
On Monday, 17 February 2020 at 19:02:50 UTC, Stefan Koch wrote: Sorry I just realized I never published the code. I am going to add it to ctfeutils. Thank you very much

Re: betterC CTFE nested switch

2020-02-21 Thread Abby via Digitalmars-d-learn
On Monday, 17 February 2020 at 19:02:50 UTC, Stefan Koch wrote: Sorry I just realized I never published the code. I am going to add it to ctfeutils. Hi Stefan, I'm sorry to bother you, I just wanted to kindly ask if you would upload the formatter to ctfeutils on github it would help me alot.

betterC CTFE nested switch

2020-02-17 Thread Abby via Digitalmars-d-learn
Hi there guys, I was trying to generated code during compile time. Bassicly I'm creating a tokenizer and I would like to generated nested switch using betterC. Basically convert something like this: enum tokens = [ ['!', '='], ['>', '='], ['>'], ]; to: switch(str[i]) { case

Re: betterC CTFE nested switch

2020-02-17 Thread Abby via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:05:46 UTC, Stefan Koch wrote: On Monday, 17 February 2020 at 10:18:32 UTC, Abby wrote: Hi there guys, I was trying to generated code during compile time. Bassicly I'm creating a tokenizer and I would like to generated nested switch using betterC. [...] I

exporting function from betterc to windows dll

2020-03-14 Thread Abby via Digitalmars-d-learn
I would like to export some functions from my bettec dll for dotnet core application in windows. Right now I have compiled dll using dmd v2.091.0-dirty simply by ´dub build´ this is the function I have extern(C) char* test_echo(const(char)* line, size_t len, ref size_t resLen) { enum

string to char* in betterC

2020-03-11 Thread Abby via Digitalmars-d-learn
What is the proper way to get char* from string which is used in c functions? toStringz does returns: /usr/include/dmd/phobos/std/array.d(965,49): Error: TypeInfo cannot be used with -betterC and I think string.ptr is not safe because it's not zero termined. So what should I do? realloc

dub libs from home directory on windows

2020-03-18 Thread Abby via Digitalmars-d-learn
Hi there, I'm using d2sqlite3 which has dependency on sqlite3.lib. When I'm building my app on windows I have a dub.sdl which has a line libs "%USERPROFILE%/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3" platform="windows-x86_64-dmd" but unless I specify full path

return val if

2020-03-22 Thread Abby via Digitalmars-d-learn
Is there a way to create a template that would do the same is glib g_return_val_if_fail() (https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-val-if-fail) I was hoping something like this would work template returnValIfFail(alias expr, alias val) {

better c fibers

2021-09-21 Thread Abby via Digitalmars-d-learn
Hi there, I'm new in dlang I specially like betterC. I was hoping that d fibers would be implemented in without using classes, but there are not. Is there another way how to use async/await in dlang better c? Thank you for your help Abby

mixins

2021-11-17 Thread Abby via Digitalmars-d-learn
Hello I would like to create validation mixin or mixin template which would return on error. Something like this: ``` mixin template Validate(a, b) { if(a > b) { writeln("invalid input"); return false; } } bool test(a,b) { mixin Validate!(a,b); on

package libs on windows

2022-02-01 Thread Abby via Digitalmars-d-learn
Hi there, I'm using d2sqlite3 package on windows with dub, the problem I have is that when I compiling the app linking fails because LINK : fatal error LNK1181: cannot open input file 'sqlite3.lib'. I would like to know if there is a way to set path to lib to downloaded with package instead