Re: Problems with string literals and etc.c.odbc.sql functions

2015-12-18 Thread Fer22f via Digitalmars-d-learn

On Friday, 18 December 2015 at 22:18:34 UTC, Adam D. Ruppe wrote:
That's what the examples on MSDN do too though, a cast. At 
first I thought the binding was missing a const, but the ODBC 
docs don't specify it as const either and cast.


The ODBC functions also have a size parameter for string 
parameters. You can set it to SQL_NTS to use the 0 terminated C 
standard. Might justify on why it's char* instead of const char*.


It looks like it's alright, then. Just one implementation detail 
I didn't notice before.


Re: Problems with string literals and etc.c.odbc.sql functions

2015-12-18 Thread Fer22f via Digitalmars-d-learn

On Friday, 18 December 2015 at 22:35:04 UTC, anonymous wrote:
If the parameter is de facto const, then the cast is ok. 
Though, maybe it should be marked const then.


I'm just worried about casts because I read somewhere that 
strings start with the number of characters inside them (probably 
in slices documentation), and not with actual content (though 
string literals probably act different in this case).


Documentation on casts say:

Casting a pointer type to and from a class type is done as a type 
paint (i.e. a reinterpret cast).


Reinterpretation is rather dangerous if strings are stored 
differently.


But this test gives me a good hope on this case:

writeln(*(cast(char*) "Test"));

Casting is what I'm going with. .dup.ptr is less clear in this 
case.


Problems with string literals and etc.c.odbc.sql functions

2015-12-18 Thread Fer22f via Digitalmars-d-learn
By the use of this tutorial 
(http://www.easysoft.com/developer/languages/c/odbc_tutorial.html), I thought it would be very straightforward to use etc.c.odbc.sqlext and etc.c.odbc.sql to create a simple odbc application. But as soon as I started, I noticed a quirk:


SQLRETURN ret;
SQLHDBC dbc;
ret = SQLDriverConnect(dbc, null, "DNS=*mydns*;", SQL_NTS,
null, 0, null, SQL_DRIVER_COMPLETE);

This gives me an error: function 
etc.c.odbc.sqlext.SQLDriverConnect (void* hdbc, void* hwnd, char* 
szConnStrIn, short cbConnStrIn, char* szConnStrOut, short 
cbConnStrOutMax, short* pcbConnStrOut, ushort fDriverCompletion) 
is not callable using argument types (void*, typeof(null), 
string, int, typeof(null), int, typeof(null), int)


After some casting, I found out it's all related to the string 
literal. I thought it would work straight off the box, after 
reading the "Interfacing to C" spec 
(http://dlang.org/spec/interfaceToC.html).


When I remove the string literal and replace it with null, it 
compiles. .ptr and .toStringz both give immutable char* 
references, and don't work. A "cast(char *)"DNS=*maydns*;"" 
works, but it feels a lot like a hack that will not work in the 
long run.


Re: We need a good code font for the function signatures on dlang.org

2015-12-17 Thread Fer22f via Digitalmars-d
On Wednesday, 16 December 2015 at 21:05:27 UTC, Andrei 
Alexandrescu wrote:
I was looking at 
https://github.com/D-Programming-Language/dlang.org/pull/1169 
and that bold sans serif proportional text for the code is 
just... well let's say it's time to replace it.


What would be a good code font to use for those?


Thanks,

Andrei


I personally use Fantasque Sans Mono, it's FOSS 
(https://github.com/belluzj/fantasque-sans). It has good support 
for lIi1 and others. But that is just an opinion, I just find it 
beautiful.


How do I read one character from stdin? (getc in C)

2015-11-14 Thread Fer22f via Digitalmars-d-learn
Hello! I'm starting to make some simple command line programs and 
one thing I miss from C is a function for getting one character 
from the input. This is for example, an "Press Any Key Program".


Anyone that has more experience can point me into a solution that 
is not deprecated? I haven't even researched about the deprecated 
options but looked into all free available D books I could find 
and I only found ways to get entire lines (even if it's just one 
character I still need to press enter).


Re: How do I read one character from stdin? (getc in C)

2015-11-14 Thread Fer22f via Digitalmars-d-learn
On Saturday, 14 November 2015 at 20:05:45 UTC, Adam D. Ruppe 
wrote:
Notably, it is pretty common on Windows, but requires an add-on 
library like ncurses on Linux.


https://github.com/adamdruppe/arsd/blob/master/terminal.d


Yea, I always though it would be kinda different between 
platforms but getc worked in VSC++ so I assumed it would work in 
D too. And you just pointed out this entire world of ncurses to 
me, I couldn't see myself not using some kind of API for building 
"graphical" terminal interfaces...


Thanks for the insight. I will take a look at your library later!


Re: How do I read one character from stdin? (getc in C)

2015-11-14 Thread Fer22f via Digitalmars-d-learn

On Saturday, 14 November 2015 at 13:53:50 UTC, BBaz wrote:

stdin.readf("%c", );
writeln(c);


Nope. In *nix this works? In Windows I still need to hit enter, 
and the character is the first one of the line I entered.


Re: D 2.068.2 test runner for Android ARM, please test and report results from your Android device

2015-11-11 Thread Fer22f via Digitalmars-d-announce

On Sunday, 1 November 2015 at 09:50:16 UTC, Joakim wrote:

https://github.com/joakim-noah/android/releases/tag/runners
You can install a test runner app or run a command-line binary.


This is from a Moto Maxx (it's a Droid Maxx rebranded), Android 
v5.0.2 and Snapdragon 805. These tests hang:


std.socket
std.stdio

Everything else went smoothly. I'm not an expertise android 
developer so I don't know how to get stacktraces from logcat, all 
I oculd get was the verbose of the test program (using "adb 
logcat test_runner:V *:S").