Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
I've done a whole bunch of looking around, and I don't see any mention of returning a dynamic array from a function. When I try it though, it just returns the .length value of the array, rather than the contents of the array. Does anyone know why this is, and what I can do to make it behave

Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Samwise via Digitalmars-d-learn
Thanks loads. I got it working using those modules. ~Sam

Re: Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:37:25 UTC, Adam D. Ruppe wrote: What code do you have now? This is the basic function. It takes all those boolean arguments and does things depending on them, and then takes any extra args that getopt didn't parse and reads them into numbs. That code

Re: Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:09:15 UTC, Adam D. Ruppe wrote: On Wednesday, 18 January 2017 at 22:51:17 UTC, Samwise wrote: numbs[] = getInp(help, file, inp, args); This is wrong, try just `numbs = getImp(...);` numbs[] = xxx will copy stuff into the existing array, which is

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent solution. It would work, but still. I'm also not sure about

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:25:47 UTC, Stefan Koch wrote: On Wednesday, 18 January 2017 at 03:11:08 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should

DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
Alright. For the sake of this argument, I'm going to post all the stuff about a really tiny boring program that quite literally does nothing, even though I found this issue when I was working with a much larger project with more functions. Basically I'm getting errors when I attempt to compile

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:51:50 UTC, ketmar wrote: On Wednesday, 18 January 2017 at 03:37:46 UTC, Samwise wrote: extern int getReturnCode() { return 4; } still does not compile using the command from above. I may very well be misunderstanding you though. yep. *both*

Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: extern(C), not simply extern. It turns off the name mangling. But really, the proper thing to do is to drop the prototype and import the module with the implementation. It's tge way modules are intended to be used. Unless

Re: Problems with setting up dub for publication

2017-03-07 Thread Samwise via Digitalmars-d-learn
On Sunday, 5 March 2017 at 01:54:22 UTC, Mike Parker wrote: ... I was getting the same problem and created on issue on this project's repository (https://github.com/ZILtoid1991/pixelperfectengine), which I think (although I don't know) was the reason this thread was created. Using the

Re: DMD Refuses to Compile Multiple Source Files

2017-03-07 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: extern(C), not simply extern. It turns off the name mangling. But really, the proper thing to do is to drop the prototype and import the module with the implementation. It's tge way modules are intended to be used. Unless

Re: Problems with Array Assignment?

2017-05-10 Thread Samwise via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 20:01:16 UTC, Adam D. Ruppe wrote: ... Thanks loads. Thanks to this my next commit is going to have quite a few improvements that clean up the engine code considerably. I appreciate the help.

Problems with Array Assignment?

2017-05-10 Thread Samwise via Digitalmars-d-learn
I'm really sure this is just a stupid mistake I made, but I can't for the life of me figure out what is going on. Basically I'm trying to assign a reference to an object to an array, and the objects exist (an explicit destructor is writing lines at the end of the program, when the objects are

Re: Problems with Array Assignment?

2017-05-10 Thread Samwise via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 13:43:54 UTC, Adam D. Ruppe wrote: In your code, I see one big mistake: --- class TileRenderer { private Tile[] tiles; /*...*/ } class CTileRenderer : TileRenderer { private CTile[] tiles; /*...*/ } --- Those are two separate arrays! Stuff examined through

Re: Problems with Array Assignment?

2017-05-10 Thread Samwise via Digitalmars-d-learn
I'm also having another problem with this program that is (sorta?) related. If you notice in my main (minus all the comments...), the code creates two tiles, then updates the renderer so that it renders those tiles. Then I create another tile in the same place as one of the first ones (not

Re: Problems with Array Assignment?

2017-05-10 Thread Samwise via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 17:54:38 UTC, Adam D. Ruppe wrote: On Wednesday, 10 May 2017 at 17:47:57 UTC, Samwise wrote: The expected behavior for this is to just see "Different Text" and "Other Text", instead of having any time to see just "Text". However, it seems that the second update