Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
csammis
Aug 26, 2003

Mental Institution

Eararaldor posted:

I'm not entirely sure if this is the right place to post this

From the list of megathreads, you want the .Net (C#, VB.NET [VB 2003, 2005, and 2008]) Questions Megathread megathread.

Adbot
ADBOT LOVES YOU

csammis
Aug 26, 2003

Mental Institution
Aside from the Dragon book, I would also recommend Modern Compiler Implementation in Java by Appel (or ML or whatever the other one is)

csammis
Aug 26, 2003

Mental Institution
For starters, populate() takes a 1-D array and you're passing it a 2-D array :confused:

csammis
Aug 26, 2003

Mental Institution
What toolkit are you using for the graphics? How are you trying to save it?

csammis
Aug 26, 2003

Mental Institution

Viper2026 posted:

For some reason, the cout statements in this portion of my code are not printing anything:

code:
        ifstream infile2("doc3", ios::in);
	LinkedSet<char> *stack2 = new LinkedSet<char>();
	
	while(!infile2.eof()){
		infile2 >> in_char;
		if(in_char == '0')
			stack2->pop_front();
		else if(in_char == '1'){
			infile2 >> in_char;
			stack2->push_front(in_char);
			cout << ":";
		}
	}
I've declared "using namespace std;" at the top and I have couts working elsewhere, but they refuse to print anything here.

EDIT: for some reason using " : " instead of just ":" makes it work...

Depending on the platform and the stream settings, cout won't flush (print its buffer) until it encounters whitespace. Now changing that or manually flushing it, that I don't remember :downs:

csammis
Aug 26, 2003

Mental Institution

Sarah Sherman posted:

Now, the probability shouldn't get above one at all. Why is it getting up to around 6?

The problem's in the loops in main(). You're incrementing num_matches multiple times per trial. It only needs to be incremented once per trial, because once two people share the same birthday, the trial is a match and you can stop checking.

csammis
Aug 26, 2003

Mental Institution

HB posted:

Looks like numMatches is not getting reset properly either. So it just adds the match onto all the matches from all previous trials.

That part looks fine (numMatches = 0 in the outermost loop), the formatting's kind of bad though.

edit:

quote:

The if statement on line 72 doesn't have brackets, so only the first statement following it is affected by the if. You've got two lines indented there, so I'm not sure if you meant for both of those lines to be in the if's body.

Seriously, fix the formatting and always use braces :eng101:

csammis
Aug 26, 2003

Mental Institution

TheBlackRoija posted:

when I try to compile it a get a whole bunch of "'WORDS' undeclared (first use in this function)" errors

Tell us what compiler you're using, what OS (and version) you're compiling on, and copy-paste the exact errors you're getting.

csammis
Aug 26, 2003

Mental Institution

greatn posted:

code:
char number[3] ;
[b]char[/b] number[0] = hundred ;
[b]char[/b] number[1] = ten ;
[b]char[/b] number[2] = one ;

I don't think you mean this. Also number should be declared with size 4, and the last entry set to '\0'

csammis
Aug 26, 2003

Mental Institution
e: IGNORE ME

csammis
Aug 26, 2003

Mental Institution

FearIt posted:

I'm trying to find all the handles of windows with a certain class type. FindWindow() only seems to return the first, how would I get the rest?

Use EnumWindows, like Pooball said, and GetClassName in the EnumWindowsProc to determine if the window is the class you want.

csammis
Aug 26, 2003

Mental Institution
The linker is saying it can't find Utility::Void. If the Void method is defined in the class Utility, you need to declare that as part of the method signature:

code:
string Utility::Join (const vector<string> vInput, const char cSeparator)
{ 
}

csammis
Aug 26, 2003

Mental Institution

Avenging Dentist posted:

just use Visual Studio which will leave the command prompt open anyway.

only if you run the program without debugging. If you start it using the debugger, it'll close on exit. It's unfortunate but true :smith:

csammis
Aug 26, 2003

Mental Institution

PT6A posted:

I'm having a hard time understanding how malloc'd memory is freed: I understand you can free it explicitly with free(), but I've seen contradicting information as to whether a malloc'd piece of memory that's being pointed to is freed when the program terminates. So, do I have to call free() for everything, or just in case I want to change the pointer that points to the malloc'd memory?

Any memory claimed by a process is reclaimed by the operating system when it terminates, but that's not the point of free() anyway. free() is used to dispose of memory your program isn't using anymore while it's running. As soon as you're done with a block you got from malloc(), free() it.


e: gently caress, a whole other page :saddowns:

csammis
Aug 26, 2003

Mental Institution
How do Entity and RenderableEntity relate? Unless it's RenderableEntity : Entity, that cast won't work - if it is, you don't need multiple inheritance on MeshInstance.

csammis
Aug 26, 2003

Mental Institution

IShallRiseAgain posted:

I am having trouble transferring an image object to a class using the get set method. I keep getting a null reference error.

1. This is C#, not C or C++. Put this in the C# megathread.

2. Use the debugger. What exactly is null when that exception happens?

csammis
Aug 26, 2003

Mental Institution
I've got an MFC-based .lib, and for the life of me I was sure there was some tool that came with Visual Studio that could show me what symbols it is exporting. Am I smoking more crack than usual and making this tool up? If I am hallucinating, what's a tool that can show me its exports?

csammis
Aug 26, 2003

Mental Institution
The answer is probably "no," but I thought I'd ask anyway: Is there a way to tell Visual Studio's linker, when it encounters a multiply defined symbol, which one is the "right" one?

The scenario is sort of asinine. Our company's application is MFC-based, v2.5 I believe, and we're having trouble throwing exceptions through it. Most of the time this is handled by a redefined AfxWinMain that handles our application's exception class - which is not derived from CException. We're getting some odd activation context exceptions in certain scenarios when an exception is thrown from a window's OnCreate handler. The architect working with me on this thinks the band-aid solution is to redeclare AfxCallWndProc to be able to handle our exceptions as well as CExceptions, but that is proving difficult because AfxCallWndProc isn't declared as extern by MFC. AfxWinMain is one of only a handful of externs in MFC, as far as I can tell, and none of the others have dick to do with the problem.

So yeah, any way to force the linker to accept a specific location of a symbol as The Symbol? :sigh:

csammis
Aug 26, 2003

Mental Institution

ehnus posted:

Have you tried decorating the symbol with __declspec(selectany)?

The symbol here is a method, AfxCallWndProc(CWnd*, HWND, UINT, WPARAM, LPARAM). selectany seems to only apply to data - trying it, I get "'selectany' can only be applied to data items with external linkage"

csammis
Aug 26, 2003

Mental Institution

rjmccall posted:

No.

Indeed. Ever notice how top doesn't show the number of cores? :v:

csammis
Aug 26, 2003

Mental Institution

hexadecimal posted:

Is endl OS specific or does it only add '\n' not "\r\n" on Windows in addition to flushing?

In text mode output streams on Win32, \n is automatically expanded to \r\n :eng101:

csammis
Aug 26, 2003

Mental Institution
MFC question:

Is there any way to render a CTreeCtrl with expand/collapse boxes and no treelines? TVS_HASBUTTONS evidently only works if TVS_HASLINES and TVS_LINESATROOT are also supplied :mad:


edit: Never mind, it does what I want with only TVS_HASBUTTONS | TVS_LINESATROOT, VS just didn't recompile the most recent changes to my resource file.

csammis
Aug 26, 2003

Mental Institution
On Windows it'll only block the thread. This is why you do blocking I/O or heavy processing in a thread other than the UI thread, so the UI remains responsive to input while blocking is happening.

Windows threads are kernel threads, I'm not sure how user threads (like pthreads on Linux) work.

csammis
Aug 26, 2003

Mental Institution

Standish posted:

Linux pthreads are kernel threads too (or to be more exact, the Native Posix Thread Library which is the default implementation of the pthreads API on any non-ancient Linux is kernel-thread-based, and so was the LinuxThreads library which preceded it.)

Whoops, maybe I meant GNU Portable Threads. It's been several years since I did any Linux development :shobon:

csammis
Aug 26, 2003

Mental Institution

more falafel please posted:

On a related note, why would an app take ~5 times as long to load in the debugger as outside it?

It might have something to do with the debugger attempting to load symbols for every module loaded by your application, which of course would not happen outside the debug environment. If you're set up to pull Windows symbols from the Microsoft symbol servers automatically instead of on-demand, that process can take a really long time.

csammis
Aug 26, 2003

Mental Institution
Did you explicitly add the library to the Linker -> Input properties?

csammis
Aug 26, 2003

Mental Institution

Morton the Mole posted:

Also you have shittons of unnecessary whitespace and brackets, but to each his own.

And your indenting sucks, but that's an objective observation and not a "to each his own" thing.

csammis
Aug 26, 2003

Mental Institution
Is #pragma once universally supported? My company's coding standard says to not use it because we compile on a whole mess of platforms and compilers, though it's entirely possible that that's out of date.

csammis
Aug 26, 2003

Mental Institution
This might be a crazy idea, but here goes.

I've got a VS 2008 solution with fourteen or so C++ projects in it, all of which get statically linked together into a single executable. Each of the fourteen projects has a string table. The VS string table editor is not aware of other projects in the solution and will happily let you create duplicate IDs that are only found when the resources are compiled together (the final .exe project includes the other projects' resources into its own). This late-notice collision is not cool, and our resource IDs are fragmented enough that it happens pretty much every time one of the developers adds a new string to any project.

One of my teammates and I got to talking today, and we wondered if there is a sane way to generate string ID numbers at compile time rather than design time; that is, convince the resource compiler - or some prebuild process - to collate the existing string tables and reassign non-colliding IDs once all the strings are known. This would result in string IDs [potentially] changing in each endstate image, but that shouldn't be a problem...right?

There are probably dozens of reasons that make this a terrible idea. For one thing, the VS string table editor wouldn't know what the gently caress, which probably will make localization difficult - I don't know the exact localization process that our company uses, only that we contract out to have it done. What I'm looking for is:

a) reasons this is stupid so I can focus my unused energy somewhere more useful
b) ways this might work at all, just so I can play around with it

It probably won't end up being valuable to anyone, but I think it's an interesting thought exercise and I'm sort of underscheduled this month :v:

csammis
Aug 26, 2003

Mental Institution

quadreb posted:

I don't know poo poo about Visual Studio, but why not just make an internal registration database keyed to the IDs that each developer drops their IDs into. Hell, you could even just do it as a wiki page.

I'm really not sure what you're suggesting with this...

csammis
Aug 26, 2003

Mental Institution

quadreb posted:

I'm suggesting a process to self-regulate the assignment of new ID numbers.

VS already autoassigns the IDs numbers, which is the problem because it does so stupidly :) I'm looking for a new process to autoassign at a different point in the cycle.


e: Even if the string table designer did understand multiple projects in a solution and could autogenerate IDs that don't conflict within a single solution, that doesn't help when multiple instances of VS (many developers) are generating the same IDs.


e2: I should mention that resource IDs are two-byte unsigned integers.

csammis fucked around with this message at 14:24 on Jun 30, 2009

csammis
Aug 26, 2003

Mental Institution

Avenging Dentist posted:

Manually fix the IDs once, never worry about it again (for a while anyway)? If it's anything like resource IDs, it's sequential. For example:

code:
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        108
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1026
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

That solves it for the single developer case (provided we go through each of the project and normalize the resource IDs so that they are sequentially increasing from 1 with no gaps), but let's say we have the following scenario:

1) One developer sets the next resource ID to start at 40000 and checks the change into TFS.
2) The next morning, all developers get that update.
3) Five developers add one string to the same project's string table. Each of those strings has ID 40000.
4) Check-in time! The first developer checks in their change, then the second has to resolve a conflict. The new string is added to #2's table, he compiles again to make sure everything works because he is a good developer, and there is a conflicting ID. Repeat for #3, 4 and 5 :suicide:

This is why I'm thinking about solutions that fix the resource IDs at compile time...that way it really doesn't matter what IDs are used at design time.

Resource lookup by integer is weak as hell, resource lookups by string fo' lyfe

csammis
Aug 26, 2003

Mental Institution

Avenging Dentist posted:

Ok so you have to resolve conflicts when merging, that's pretty much par for the course with development.

Conflict resolution is a fact of development life...that doesn't mean effort shouldn't be taken to reduce the incidence of conflicts.

Avenging Dentist posted:

String IDs don't exist in the VS resource thing-a-ma-bobber though.

Not for C++ anyway. The C# resource editor exposes the string table using string IDs, though it may use integers under the hood.

csammis
Aug 26, 2003

Mental Institution

Contero posted:

Why can't switch look something like this:
code:
switch (variable) {
   case(one, two, three) { code; }
   case(52542) { 
      more code;
      bla bla bla;
      if (something) break;
      bla bla;
   }
   default { eat an rear end; }
}

How does your syntax handle fall-through?

code:
switch (var)
{
  case 1:
    do_some_pre_op();
  case 2:
  case 3:
    do_some_op();
    break;
  case 4:
    do_some_other_op();
    break;
}

csammis
Aug 26, 2003

Mental Institution

Contero posted:

Well it doesn't, but I'd argue that fall-through is lame anyway.

You're right, two comparisons are better than one!

And what AD said about this being why switch statements are useful in the first place.

csammis
Aug 26, 2003

Mental Institution
Maybe reinterpret_cast was feeling underrepresented in his codebase?

csammis
Aug 26, 2003

Mental Institution

ultimateforce posted:

My problem is that I keep getting the same random numbers each time.

That isn't the only problem with what you posted, but I'm going to guess that you never seed the random number generator in the code you aren't showing us.

csammis
Aug 26, 2003

Mental Institution

Dijkstracula posted:

Also, http://beej.us/guide/bgnet/ or better yet, http://www.unpbook.com/

Goddamn you, for a minute I was excited about a website I could direct socket questions to that was better than Beej (which is great) :(

csammis
Aug 26, 2003

Mental Institution

Nigglypuff posted:

what would be the idiomatic, non-idiotic contraction of "·emits a warning at compilation"

"emits a warning" because obviously it's at compile time :colbert:

Adbot
ADBOT LOVES YOU

csammis
Aug 26, 2003

Mental Institution

And then hit up the C# thread.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply