Re: Down the VisualD0.3.38-1.exe ,found virus!
On Monday, 12 May 2014 at 06:36:10 UTC, FrankLike wrote: There are some quotes missing when building the Debug configuration. I have committed a fix and also added the missing file reported in your other message (IIRC it is not needed by every VS SDK). Sorry,Rainer Schuetze, And there is a little error in sdk.bat '(echo unexpected Visual Studio SDK installation at %VSISDKINC% && exit /B 1)' %VSISDKINC% should be "%VSISDKINC%" Thank you again. Frank
Re: Down the VisualD0.3.38-1.exe ,found virus!
There are some quotes missing when building the Debug configuration. I have committed a fix and also added the missing file reported in your other message (IIRC it is not needed by every VS SDK). Sorry,Rainer Schuetze, Here is some error when compile the VisualD: --ERROR START Building Resources\pkgcmd.cto Command Line set PATH=D:\D\dmd2\windows\bin;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\\bin;%PATH% set DMD_LIB=D:\D\dmd2\windows\lib set VS9SDKBIN=c:\l\vs9SDK\VisualStudioIntegration\Tools\Bin set CTC=%VS9SDKBIN%\CTC.exe if not exist "%CTC%" goto no_CTC if not exist "C:\Program Files (x86)\Microsoft Visual Studio 10.0\\Common7\Tools\vsvars32.bat" goto no_CTC set PATH=%PATH%;%VS9SDKBIN% call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\\Common7\Tools\vsvars32.bat" if errorlevel 1 goto reportError "%CTC%" Resources\pkgcmd.ctc Resources\pkgcmd.cto -Ccl -I. goto reportError :no_CTC echo Warning: CTC.exe not found in %VS9SDKBIN%. echo It is part of the VS2008 SDK and is needed to compile Resources\pkgcmd.ctc if not exist Resources\pkgcmd.cto exit 1 echo Resources\pkgcmd.cto exists, so it is assumed to be up to date. echo If the project rebuilt again and again with this message, touch Resources\pkgcmd.cto to make it newer than Resources\pkgcmd.ctc :reportError :reportError if errorlevel 1 echo Building Resources\pkgcmd.cto failed! Output Warning: CTC.exe not found in c:\l\vs9SDK\VisualStudioIntegration\Tools\Bin. It is part of the VS2008 SDK and is needed to compile Resources\pkgcmd.ctc -ERROR END- I found it always to overwite the file 'visuald\visuald\Resources\pkgcmd.cto.build.cmd',let the 'VS9SDKBIN=c:\l\vs9SDK\VisualStudioIntegration\Tools\Bin' not use '%VSSDK100Install%VisualStudioIntegration\Tools\Bin' . Then failed. Thank you again. Frank
Re: Down the VisualD0.3.38-1.exe ,found virus!
There are some quotes missing when building the Debug configuration. I have committed a fix and also added the missing file reported in your other message (IIRC it is not needed by every VS SDK). Thank you,I'll try it. Frank
Re: Curl Exception
On Sunday, 11 May 2014 at 16:17:20 UTC, Nick Sabalausky wrote: Sorry, I haven't really used the curl stuff yet, so I can't be a bigger help, but a couple notes below: It's alright. I'm actually up for any information right now. Access Violation, despite its wording, isn't usually about user permissions. It's the Windows version of a segfault. Usually means a null pointer was dereferenced, or a freed pointer was used, or an otherwise bad pointer or buffer overflow, etc. If you're really unlucky those can be a result of memory corruption, but that's usually not the case. If you recompile with "-g" ("enable debugging symbols"), then those annoyingly meaningless addresses will change into a proper stack trace. (Or try "-gc" if "-g" doesn't work.) Weird. I am sure I wasn't dealing with any pointers, and the Curl Documentation did say that it was safe. Though I also tried Updating my compiler and libraries and compiling with the "-g" flag lead me to a errno(STD Exception) giving me with the phrase "(no error)". This only happened in C::B(I'm gonna try Programmer's Notebook if this is actually the fault of C::B) Though outside the IDE it's just spewing out the same error over and over again. The error in the actual program outside the IDE was *bypassed* when inside the IDE, only giving an Access Violation error(pre-update) or STD Exception(post-update) Is that the same error you get if you try to give it a pem file you *know* doesn't exist? If so, then maybe it's not looking in the directory you expect. Try giving it a full absolute path to the pem file. If that works, then it's probably looking in the directory you're running from instead of the directory where it actually exists. If so, you can use std.file.thisExePath() and build your path relative to that (or just stick with an absolute path). The program is pretty much finding the certificate as it's not the same error as not finding the file. It's just nagging at the fact that there maybe a path mistake(which can't be true since it's detecting it) and access rights(now how do I configure them access rights?) You can also try opening your pem file directly: auto pemFile = File("cacert.pem"); Unfortunately, HTTP.caInfo(); takes in a "const char[]" so I can't try that option. See what happens if you do that. It won't fix the problem, but seeing what it does it should help give you a better idea of what's going on. Though in the Code:: Blocks IDE there was the object.Error Access Violation error And in the actual program(.exe) this : http://pastebin.com/8MmPLg2Q Though I'm also up for not verifying the link but I still can't figure out how. Anyway, can anyone give me an idea what went wrong? Thanks for the information however. :)
Re: question about passing associative array to a function
On Sunday, 11 May 2014 at 14:46:35 UTC, rbutler wrote: I have searched and can not understand something about passing AAs to a function. I have reduced the gist of the question to a tiny program below. If I put "ref" in the function stmt it works, i.e.: ref int[int] aa My confusion is that AAs are supposed to be passed as refs anyway, so I do not understand why I should have to use ref to make it work. Related, it also works if I UN-comment the lined[9] = 9; Thanks for any helpful comments you can make. --rbutler import std.stdio; void test(int[int] aa, int x) { aa[x] = x; aa[8] = 8; } void main() { int[int] d; writeln(d.length); // d[9] = 9; test(d, 0); writeln(d); } The AA is passed by value but its underlying data is referenced, making the copy cheap. The snippet below also shows the same behaviour even when the AA has data in it before calling the function. --- void func(string[int] aa) { writefln("[FUNC1]&aa:%s=%s", &aa, aa); // Reassign the data here in func()'s copy and // main never sees it aa = [2:"two"]; writefln("[FUNC2]&aa:%s=%s", &aa, aa); } void main() { string[int] aa; aa[1] = "one"; writefln("[MAIN1]&aa:%s=%s", &aa, aa); func(aa); writefln("[MAIN2]&aa:%s=%s", &aa, aa); } --- It is the same as passing a C++ shared_ptr<> by value. Cheers, ed
Re: question about passing associative array to a function
On Sun, 11 May 2014 17:00:13 + > Remind me again why we can't just change this to a sensible > initial state? Or at least add a .initialize()? All reference types have a null init value. Arrays and classes have the exact same issue as AAs. Anything else would require not only allocating memory but would require that that state persist from compile time to runtime, because the init value must be known at compile time, and there are many cases, where a variable exists at compile time (e.g. a module-level or static variable), making delayed initialization problematic. Previously, it was impossible to allocate anything other than arrays at compile time and have it's state persist through to runtime, though it's not possible to do that with classes (I don't know about AAs). So, it _might_ now be possible to make it so that AAs had an init value other than null, but because there's only one init value per type, even if the init value for AAs wasn't null, it wouldn't solve the problem. It would just result in all AAs of the same type sharing the same value unless they were directly initialized rather than having their init value used. Essentially, the way that default-initialization works in D makes it so that a default-initialized AA can't be its own value like you're looking for. For that, we'd need default construction (like C++ has), but then we'd lose out on the benefits of having a known init value for all types and would have the problems that that was meant to solve. It causes us problems with structs too for similar reasons (the lack of default construction there also gets complained about fairly frequently). Ultimately, it's a set of tradeoffs, and you're running into the negative side of this particular one. - Jonathan M Davis
Re: Configuring Phobos from the 1-click installer
El 11/05/14 07:34, Moses via Digitalmars-d-learn ha escrit: > On Sunday, 11 May 2014 at 04:33:24 UTC, Ali Çehreli wrote: >> On 05/10/2014 07:12 PM, Moses wrote: >>> After using the 1-click Ubuntu installer, I'm having trouble figuring >>> out how to import standard library functions for Phobos. I get the message: >>> >>> Error: module io is in file 'std/std/io.d' which cannot be read >> >> Judging from the repeated stds up there I think you put a dot before io: >> >> import std.std.io; // <-- WRONG >> >> The second dot should not be there. Do this instead: >> >> import std.stdio; // <-- correct >> >> Ali > > > Thanks, I also found that I need to include the flag > -I/usr/include/dmd/phobos to get it to compile. I tried doing: > > export PATH=$PATH:/usr/include/dmd/phobos > > but apparently I still need the -I flag. Is there another way to get around > this? > PATH environment variable is not related at all with phobos2 sources paths. All Linux packages (Ubuntu too) includes "-I/usr/include/dmd/phobos" on /etc/dmd.conf configuration file. If you need to explicit pass this argument to dmd compiler, may be due to several reasons. - You've edited your "/etc/dmd.conf" file. - You've created a new "dmd.conf" on your current directory, on you home directory or on dmd command directory (/usr/bin/). Any "dmd.conf" file on these places, overrides "/etc/dmd.conf" Take a look at: $ cat /etc/dmd.conf Regard, -- Jordi Sayol
Re: Down the VisualD0.3.38-1.exe ,found virus!
On 10.05.2014 10:42, FrankLike wrote: I've been using VisualD for a long time without problems. If it makes you nervous, you can get the source from Github and compile it yourself. Hello,Meta When I compile the Visual D projects: at first,I compile the 'build' project,then get some error: --START ALL BUILD: PROJECT: c2d, Debug Win32 -- Building ..\bin\Debug\c2d.lib... Build time: 1 s -- START ALL BUILD: PROJECT: vsi2d, Debug Win32 -- Building ..\bin\Debug\vsi2d.exe... Converting debug information... Build time: 1 s -- START ALL BUILD: PROJECT: build, Debug Win32 -- Building ..\bin\Debug\build.sdk... 'C:\Program' is not recognized as an internal or external command, operable program or batch file. Building ..\bin\Debug\dte_idl.success failed! Here is my VSSDK AND WINSDK: VSSDK100Install = C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1 WindowsSdkDir = C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A How can I do? Thank you. There are some quotes missing when building the Debug configuration. I have committed a fix and also added the missing file reported in your other message (IIRC it is not needed by every VS SDK).
Re: Configuring Phobos from the 1-click installer
Thanks, I also found that I need to include the flag -I/usr/include/dmd/phobos to get it to compile. I tried doing: export PATH=$PATH:/usr/include/dmd/phobos but apparently I still need the -I flag. Is there another way to get around this? Does your /etc directory contain dmd.conf file? You can add standard flags there Example of dmd.conf: [Environment] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import Yes, my dmd.conf file already has those paths.
Re: question about passing associative array to a function
On 05/11/2014 10:00 AM, John Colvin wrote: > On Sunday, 11 May 2014 at 16:54:18 UTC, Ali Çehreli wrote: >> On 05/11/2014 07:46 AM, rbutler wrote: >> >> > I have searched and can not understand something about >> passing AAs to a >> > function. >> > I have reduced the gist of the question to a tiny program >> below. >> > If I put "ref" in the function stmt it works, i.e.: >> > ref int[int] aa >> > My confusion is that AAs are supposed to be passed as refs >> anyway, so I do >> > not understand why I should have to use ref to make it work. >> > >> > Related, it also works if I UN-comment the lined[9] = 9; >> > >> > Thanks for any helpful comments you can make. >> > --rbutler >> > >> > import std.stdio; >> > >> > void test(int[int] aa, int x) { >> > aa[x] = x; >> > aa[8] = 8; >> > } >> > >> > void main() { >> > int[int] d; >> > writeln(d.length); >> > // d[9] = 9; >> > test(d, 0); >> > writeln(d); >> > } >> >> The problem is with the initial state of associative arrays, which >> happens to be null. When AAs are copied when null, both copies are >> null, not being associated with anything, not even an initial table to >> store the hash buckets in. As a result, null AAs cannot be references >> to each other's (non existent) data. >> >> When a null AA starts receiving data, it first creates its own data >> memory but the other one cannot know about that data. >> >> ref parameter works because then there is only one AA to speak of. >> >> d[9] entry works as well because then the first AA is not null. >> >> Ali > > Remind me again why we can't just change this to a sensible initial > state? First, I am not familiar with the current implementation of AAs and I deduced what I've written just from the behavior. I think it is this way primarily for lazy initialization so that nothing is done until there is at least one element. It could still work as expected though if there were another level of indirection, which would naturally add some cost. (Although, lazy initialization brings a constant cost as well, right? In the form of "has this been initialized yet"; but that cost is as cheap as checking the value of a local variable. On the other hand, an indirection would be cache-unfriendly. And this is pure speculation... :p) > Or at least add a .initialize()? Your initAA() function seems to be the only way that a user can manage to do that. Although, it would help if we renamed it as initialize() and added a template constraint so that it is called only for AAs. Ali
Re: question about passing associative array to a function
On Sunday, 11 May 2014 at 16:54:18 UTC, Ali Çehreli wrote: On 05/11/2014 07:46 AM, rbutler wrote: > I have searched and can not understand something about passing AAs to a > function. > I have reduced the gist of the question to a tiny program below. > If I put "ref" in the function stmt it works, i.e.: > ref int[int] aa > My confusion is that AAs are supposed to be passed as refs anyway, so I do > not understand why I should have to use ref to make it work. > > Related, it also works if I UN-comment the lined[9] = 9; > > Thanks for any helpful comments you can make. > --rbutler > > import std.stdio; > > void test(int[int] aa, int x) { > aa[x] = x; > aa[8] = 8; > } > > void main() { > int[int] d; > writeln(d.length); > // d[9] = 9; > test(d, 0); > writeln(d); > } The problem is with the initial state of associative arrays, which happens to be null. When AAs are copied when null, both copies are null, not being associated with anything, not even an initial table to store the hash buckets in. As a result, null AAs cannot be references to each other's (non existent) data. When a null AA starts receiving data, it first creates its own data memory but the other one cannot know about that data. ref parameter works because then there is only one AA to speak of. d[9] entry works as well because then the first AA is not null. Ali Remind me again why we can't just change this to a sensible initial state? Or at least add a .initialize()?
Re: question about passing associative array to a function
On 05/11/2014 07:46 AM, rbutler wrote: > I have searched and can not understand something about passing AAs to a > function. > I have reduced the gist of the question to a tiny program below. > If I put "ref" in the function stmt it works, i.e.: > ref int[int] aa > My confusion is that AAs are supposed to be passed as refs anyway, so I do > not understand why I should have to use ref to make it work. > > Related, it also works if I UN-comment the lined[9] = 9; > > Thanks for any helpful comments you can make. > --rbutler > > import std.stdio; > > void test(int[int] aa, int x) { > aa[x] = x; > aa[8] = 8; > } > > void main() { > int[int] d; > writeln(d.length); > // d[9] = 9; > test(d, 0); > writeln(d); > } The problem is with the initial state of associative arrays, which happens to be null. When AAs are copied when null, both copies are null, not being associated with anything, not even an initial table to store the hash buckets in. As a result, null AAs cannot be references to each other's (non existent) data. When a null AA starts receiving data, it first creates its own data memory but the other one cannot know about that data. ref parameter works because then there is only one AA to speak of. d[9] entry works as well because then the first AA is not null. Ali
Re: Curl Exception
On 5/10/2014 9:02 AM, Jack wrote: First off a rant: I use the Code::Blocks IDE and at times it has been proven to a double-edged source because of various issueslike this one: http://forum.dlang.org/thread/ndeyzrifseipuebvy...@forum.dlang.org) and am now itching to search for other IDEs to suit my needs. I switched from C::B to Programmer's Notepad 2 several years ago, and I've been happy with it: http://www.pnotepad.org/ It's good if you're looking for a light editor rather than a heavy-duty IDE. Otherwise, there's VisualD and Mono-D which I hear are good. Now on to the question: Anyway, I was using std.net.curl to implement an auto updater for my program. Sorry, I haven't really used the curl stuff yet, so I can't be a bigger help, but a couple notes below: Function code is this: http://pastebin.com/i6WnwJF5(links removed due to it having private content. Original host is https://dropbox.com) And the overall function was working fine in the IDE except for an Access Violation that I thought would work itself out when it's (run by administrator). Access Violation, despite its wording, isn't usually about user permissions. It's the Windows version of a segfault. Usually means a null pointer was dereferenced, or a freed pointer was used, or an otherwise bad pointer or buffer overflow, etc. If you're really unlucky those can be a result of memory corruption, but that's usually not the case. So I Exported it to a folder with all necessary files, including the "cacert.pem" file and run it. Well this little error popped out : http://pastebin.com/8MmPLg2Q If you recompile with "-g" ("enable debugging symbols"), then those annoyingly meaningless addresses will change into a proper stack trace. (Or try "-gc" if "-g" doesn't work.) Is that the same error you get if you try to give it a pem file you *know* doesn't exist? If so, then maybe it's not looking in the directory you expect. Try giving it a full absolute path to the pem file. If that works, then it's probably looking in the directory you're running from instead of the directory where it actually exists. If so, you can use std.file.thisExePath() and build your path relative to that (or just stick with an absolute path). You can also try opening your pem file directly: auto pemFile = File("cacert.pem"); See what happens if you do that. It won't fix the problem, but seeing what it does it should help give you a better idea of what's going on. Though in the Code:: Blocks IDE there was the object.Error Access Violation error And in the actual program(.exe) this : http://pastebin.com/8MmPLg2Q Though I'm also up for not verifying the link but I still can't figure out how. Anyway, can anyone give me an idea what went wrong?
Re: question about passing associative array to a function
On Sunday, 11 May 2014 at 15:22:29 UTC, John Colvin wrote: On Sunday, 11 May 2014 at 14:46:35 UTC, rbutler wrote: I have searched and can not understand something about passing AAs to a function. I have reduced the gist of the question to a tiny program below. If I put "ref" in the function stmt it works, i.e.: ref int[int] aa My confusion is that AAs are supposed to be passed as refs anyway, so I do not understand why I should have to use ref to make it work. Related, it also works if I UN-comment the lined[9] = 9; Thanks for any helpful comments you can make. --rbutler import std.stdio; void test(int[int] aa, int x) { aa[x] = x; aa[8] = 8; } void main() { int[int] d; writeln(d.length); // d[9] = 9; test(d, 0); writeln(d); } There are problems with the implementation of associative arrays. What you are seeing above is a consequence of the associative array not being correctly initialised (I think...). I often create my associative arrays with the following function to avoid the problem you're having: /// Hack to properly initialise an empty AA auto initAA(T)() { T t = [typeof(T.keys[0]).init : typeof(T.values[0]).init]; t.remove(typeof(T.keys[0]).init); return t; } import std.stdio; void test(int[int] aa, int x) { aa[x] = x; aa[8] = 8; } void main() { int[int] d = initAA!(int[int]); test(d, 0); writeln(d); } OK. :-) That makes it difficult to talk about in a classroom, especially when trying to stress adherence to the principle of least surprise. Thanks very much for the quick reply.
Re: question about passing associative array to a function
On Sunday, 11 May 2014 at 14:46:35 UTC, rbutler wrote: I have searched and can not understand something about passing AAs to a function. I have reduced the gist of the question to a tiny program below. If I put "ref" in the function stmt it works, i.e.: ref int[int] aa My confusion is that AAs are supposed to be passed as refs anyway, so I do not understand why I should have to use ref to make it work. Related, it also works if I UN-comment the lined[9] = 9; Thanks for any helpful comments you can make. --rbutler import std.stdio; void test(int[int] aa, int x) { aa[x] = x; aa[8] = 8; } void main() { int[int] d; writeln(d.length); // d[9] = 9; test(d, 0); writeln(d); } There are problems with the implementation of associative arrays. What you are seeing above is a consequence of the associative array not being correctly initialised (I think...). I often create my associative arrays with the following function to avoid the problem you're having: /// Hack to properly initialise an empty AA auto initAA(T)() { T t = [typeof(T.keys[0]).init : typeof(T.values[0]).init]; t.remove(typeof(T.keys[0]).init); return t; } import std.stdio; void test(int[int] aa, int x) { aa[x] = x; aa[8] = 8; } void main() { int[int] d = initAA!(int[int]); test(d, 0); writeln(d); }
question about passing associative array to a function
I have searched and can not understand something about passing AAs to a function. I have reduced the gist of the question to a tiny program below. If I put "ref" in the function stmt it works, i.e.: ref int[int] aa My confusion is that AAs are supposed to be passed as refs anyway, so I do not understand why I should have to use ref to make it work. Related, it also works if I UN-comment the lined[9] = 9; Thanks for any helpful comments you can make. --rbutler import std.stdio; void test(int[int] aa, int x) { aa[x] = x; aa[8] = 8; } void main() { int[int] d; writeln(d.length); // d[9] = 9; test(d, 0); writeln(d); }
Re: why can't I call const methods on shared objects?
On Friday, 9 May 2014 at 21:58:41 UTC, Steven Schveighoffer wrote: On Fri, 09 May 2014 17:45:37 -0400, Vlad Levenfeld wrote: Is there any way to declare a method as "safe regardless of shared/mutability/etc" (or some other way to avoid cast(Type)object.property every time I want to check a property which won't affect any state)? Not really for shared. For everything else, there's const for value properties, and inout for reference properties. Shared is quite different, because the method has to be cognizant of race conditions. It has to be implemented differently. Casting away shared is somewhat dangerous, but OK if you logically know there is no race condition. -Steve You could just declare the function as "immutable". But then, it'll only work on immutable types. But then again, that would be the only way to actually statically and safely guarantee there are no race conditions.
Re: why can't I call const methods on shared objects?
On Friday, 9 May 2014 at 21:37:37 UTC, Vlad Levenfeld wrote: Error: non-shared const method is not callable using a shared mutable object Why not? If the method is const, it can't modify the object anyway. Because thread-safety isn't only a problem when writing to memory, reads must also be carefully dealt with.
Re: Messy code in console
On Sunday, 11 May 2014 at 08:48:43 UTC, FreeSlave wrote: On Sunday, 11 May 2014 at 07:43:07 UTC, Kagamin wrote: Known bug https://issues.dlang.org/show_bug.cgi?id=2742 It's not bug. Write-functions are designed to output text to stdout, and it's issue of programmer to make sure that expected "acceptor" can interpret them properly. Note that stdout may be redirected to file or be part of pipe, that does nothing with cmd console. OK, just tested it: after a program calls SetConsoleOutputCP(CP_UTF8); it's able to print utf-8 text correctly, but if it fails to reset the codepage back, the console remains in utf-8, so other programs will fail to print text in oem encoding in such console. If this program runs other programs, they fail to print oem text to this console, because the console expects utf-8.
Re: Temporary silence output (stdout)
On Saturday, 10 May 2014 at 20:24:50 UTC, MarisaLovesUsAll wrote: Hi! I sometimes got a useless messages in stdout from SDL_Image library, and I want to temporary silence it. How do I do? Are you sure it's stdout, not stderr? For the latter, you would need to redirect FD 2, not FD 1: ... auto ex = PushFD!2("/dev/null".ptr); ...
Re: Messy code in console
On Sunday, 11 May 2014 at 07:43:07 UTC, Kagamin wrote: Known bug https://issues.dlang.org/show_bug.cgi?id=2742 It's not bug. Write-functions are designed to output text to stdout, and it's issue of programmer to make sure that expected "acceptor" can interpret them properly. Note that stdout may be redirected to file or be part of pipe, that does nothing with cmd console.
Re: Messy code in console
The problem has been solved with your help. Thank you very much. On 2014年5月11日 格林尼治标准时间+0800下午3时43分41秒, FrankLike via Digitalmars-d-learn wrote: >On Sunday, 11 May 2014 at 06:35:26 UTC, IceNature via >Digitalmars-d-learn wrote: >> Thank you for your help. But if I change the default console >> encoding,will it affect other programs,making other console >> program show messy code? > >Don't affect,and you must set the font to a unicode font ,such >as Lucida. > > >.
Re: Temporary silence output (stdout)
On Saturday, 10 May 2014 at 20:24:50 UTC, MarisaLovesUsAll wrote: Hi! I sometimes got a useless messages in stdout from SDL_Image library, and I want to temporary silence it. How do I do? You can temporary redirect output to file. Example (on C): #include #include #include int main () { int stdout_copy = dup(STDOUT_FILENO); close (STDOUT_FILENO); int stdout_file = creat("myfile.txt", O_RDWR); //it obtains the lowest free descriptor - 1, i.e. stdout. printf("Hello file\n"); fflush(stdout); //don't forget to flush close(stdout_file); dup2(stdout_copy, STDOUT_FILENO); printf("Hello console\n"); return 0; } But it's not very portable, you probably will need to write something other for Windows system. And there are no checks for errors in this example. Also in SDL specific case it seems like it should redirect by default - http://sdl.beuc.net/sdl.wiki/FAQ_Console but I don't know whether it's true or not for SDL_Image.
Re: Messy code in console
On Sunday, 11 May 2014 at 06:35:26 UTC, IceNature via Digitalmars-d-learn wrote: Thank you for your help. But if I change the default console encoding,will it affect other programs,making other console program show messy code? Don't affect,and you must set the font to a unicode font ,such as Lucida.
Re: Messy code in console
Known bug https://issues.dlang.org/show_bug.cgi?id=2742
Re: Configuring Phobos from the 1-click installer
On Sunday, 11 May 2014 at 05:34:38 UTC, Moses wrote: On Sunday, 11 May 2014 at 04:33:24 UTC, Ali Çehreli wrote: On 05/10/2014 07:12 PM, Moses wrote: After using the 1-click Ubuntu installer, I'm having trouble figuring out how to import standard library functions for Phobos. I get the message: Error: module io is in file 'std/std/io.d' which cannot be read Judging from the repeated stds up there I think you put a dot before io: import std.std.io; // <-- WRONG The second dot should not be there. Do this instead: import std.stdio; // <-- correct Ali Thanks, I also found that I need to include the flag -I/usr/include/dmd/phobos to get it to compile. I tried doing: export PATH=$PATH:/usr/include/dmd/phobos but apparently I still need the -I flag. Is there another way to get around this? Does your /etc directory contain dmd.conf file? You can add standard flags there Example of dmd.conf: [Environment] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import
Re: why can't I call const methods on shared objects?
On Sunday, 11 May 2014 at 07:31:10 UTC, FreeSlave wrote: On Friday, 9 May 2014 at 21:42:14 UTC, Vlad Levenfeld wrote: Is this still the case if the method is const or pure? Const methods still require synchronization, because other threads may change some data, needed by const method while method is executed, and then you may get wrong results. Consider: class Point { public: float x; float y; } I send before I end( class Point { public: float x; float y; Tuple!(float, float) getLengthAndAngle() const { float l = sqrt(x*x+y*y); //other thread change x or y float a = atan2(x, y); return tuple(l, a); } }
Re: why can't I call const methods on shared objects?
On Friday, 9 May 2014 at 21:42:14 UTC, Vlad Levenfeld wrote: Is this still the case if the method is const or pure? Const methods still require synchronization, because other threads may change some data, needed by const method while method is executed, and then you may get wrong results. Consider: class Point { public: float x; float y; }