Hi,
I want to allocate a buffer which I use in a function which reads data
from socket.
So I did as a first line in that function:
static char[] buffer=new char[4096];
The compiler (2.062) complained that it cannot evaluate new char[] at
compile time.
I Then tried to move the declaration
Am Tue, 19 Feb 2013 16:43:09 -0800
schrieb Charles Hixson charleshi...@earthlink.net:
I have, towards the start of my file:
/** Macros:
* Note = $(BR)$(BIG$(B$(GREEN Note:)))
* Todo = brfont color=redbToDo:/b $0/fontbr
* Em = $(B$(BLUE $0))
* DoNotUse = $(B Do Not Use $0)
*/
On Wednesday, 20 February 2013 at 08:03:48 UTC, Lubos Pintes
wrote:
Hi,
I want to allocate a buffer which I use in a function which
reads data from socket.
So I did as a first line in that function:
static char[] buffer=new char[4096];
The compiler (2.062) complained that it cannot evaluate
Lubos Pintes:
Allocating statically sized array bloats the executable.
Because char.init is not '\0'. Try to initialize it with zero:
char[10_000] a = '\0';
void main() {}
Bye,
bearophile
On Tuesday, 19 February 2013 at 17:40:03 UTC, John Colvin wrote:
D doesn't use null termination for it's strings, strings are
immutable(char)[]. You can form a D slice from a pointer by
going
slice = ptr[0..length]
where length is the length of the array the pointer represents.
You can't
Ok thank you. I see now.
One unrelated question: Why the safe attribute has the at-sign, while
nothrow doesn't?
Dňa 20. 2. 2013 11:19 monarch_dodra wrote / napísal(a):
On Wednesday, 20 February 2013 at 08:03:48 UTC, Lubos Pintes wrote:
Hi,
I want to allocate a buffer which I use in a
Lubos Pintes:
Why the safe attribute has the at-sign, while nothrow doesn't?
Historical accidents... There is no rhyme reason in that.
Bye,
bearophile
I tried extern (C) which has some advantages. However, it still
doesn't produce the desired result (tried slicing too).
extern(C) {
export void synthesize(ref char[] str) {
printf(Incoming printf: %s\n, str);
writefln(writefln %s, str);
writefln(writefln %s,
On Wed, 20 Feb 2013 03:03:49 -0500, Lubos Pintes lubos.pin...@gmail.com
wrote:
Hi,
I want to allocate a buffer which I use in a function which reads data
from socket.
So I did as a first line in that function:
static char[] buffer=new char[4096];
The compiler (2.062) complained that it
On Wednesday, 20 February 2013 at 12:48:53 UTC, Chris wrote:
I tried extern (C) which has some advantages. However, it still
doesn't produce the desired result (tried slicing too).
extern(C) {
export void synthesize(ref char[] str) {
printf(Incoming printf: %s\n, str);
On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker wrote:
Your function is being called from Python, correct? Then in
addition to the extern(C), the argument needs to be a char*,
not a D array or a reference to one.
Correct, and it works _now_*! The lines
printf(Incoming printf:
Chris:
extern (C) {export void printThis(char* str);}
Maybe the D wiki should contain info to save some time and
experiments to people.
Possible alternative syntax:
extern(C) export void printThis(char* str);
Also, think if you want some const:
extern(C) export void
On Wednesday, 20 February 2013 at 14:28:06 UTC, Chris wrote:
On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker
wrote:
Your function is being called from Python, correct? Then in
addition to the extern(C), the argument needs to be a char*,
not a D array or a reference to one.
On Wednesday, 20 February 2013 at 14:36:56 UTC, bearophile wrote:
Chris:
extern (C) {export void printThis(char* str);}
Maybe the D wiki should contain info to save some time and
experiments to people.
I agree and I am glad that the people on this forum are always
willing to help. I will
On Wednesday, 20 February 2013 at 14:43:06 UTC, John Colvin wrote:
On Wednesday, 20 February 2013 at 14:28:06 UTC, Chris wrote:
On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker
wrote:
Your function is being called from Python, correct? Then in
addition to the extern(C), the argument
On 02/20/2013 12:51 AM, Johannes Pfau wrote:
Am Tue, 19 Feb 2013 16:43:09 -0800
schrieb Charles Hixsoncharleshi...@earthlink.net:
I have, towards the start of my file:
/** Macros:
* Note = $(BR)$(BIG$(B$(GREEN Note:)))
* Todo =brfont color=redbToDo:/b $0/fontbr
* Em = $(B$(BLUE
On Wednesday, 20 February 2013 at 07:54:19 UTC, monarch_dodra
wrote:
Note that an Error is not an Exception, and an Exception is not
an Error. Both, however, are Throwable's. If you want to catch
an *anything*, then catch a Throwable.
As already mentioned though, catching an Error is not
On 02/20/2013 12:51 AM, Johannes Pfau wrote:
Am Tue, 19 Feb 2013 16:43:09 -0800
schrieb Charles Hixsoncharleshi...@earthlink.net:
I have, towards the start of my file:
/** Macros:
* Note = $(BR)$(BIG$(B$(GREEN Note:)))
* Todo =brfont color=redbToDo:/b $0/fontbr
* Em = $(B$(BLUE
On Wed, Feb 20, 2013 at 11:02:51AM -0800, Charles Hixson wrote:
On 02/20/2013 12:51 AM, Johannes Pfau wrote:
Am Tue, 19 Feb 2013 16:43:09 -0800
schrieb Charles Hixsoncharleshi...@earthlink.net:
I have, towards the start of my file:
/** Macros:
* Note = $(BR)$(BIG$(B$(GREEN
On 02/20/2013 11:10 AM, H. S. Teoh wrote:
On Wed, Feb 20, 2013 at 11:02:51AM -0800, Charles Hixson wrote:
On 02/20/2013 12:51 AM, Johannes Pfau wrote:
Am Tue, 19 Feb 2013 16:43:09 -0800
schrieb Charles Hixsoncharleshi...@earthlink.net:
I have, towards the start of my file:
/** Macros:
Hello to everyone, and thank you for your help!
Sorry for the delay in response, as I was busy with family
matters. However, upon returning today, and with everyone's help,
I have successfully gotten it to work. The code below worked out
swimmingly:
auto reg = regex(`[
On 18/02/2013 21:25, Michael wrote:
Yes, it's comes from C#.
So, there is no static for classes at module level. Good to have a msg
for it at compile-time.
import std.stdio;
public final abstract class Test
{
static this() { writeln(in static ctor); }
static :
void foo() {
On 02/20/2013 11:02 AM, Charles Hixson wrote:
On 02/20/2013 12:51 AM, Johannes Pfau wrote:
Am Tue, 19 Feb 2013 16:43:09 -0800
schrieb Charles Hixsoncharleshi...@earthlink.net:
I have, towards the start of my file:
/** Macros:
* Note = $(BR)$(BIG$(B$(GREEN Note:)))
* Todo =brfont
23 matches
Mail list logo