|
Does VS still do that thing where if you use standard library string functions it tells you to use special Microsoft ones instead?
|
# ? Sep 23, 2011 08:24 |
|
|
# ? Jun 8, 2024 05:50 |
|
Qwertycoatl posted:Does VS still do that thing where if you use standard library string functions it tells you to use special Microsoft ones instead? Yep. You can disable the warning though (it's C4996).
|
# ? Sep 23, 2011 12:34 |
|
roomforthetuna posted:The other thing VC++ does that's bad for cross-platforming is that it does everything with vcproj files where the more-standard is makefiles. That's pretty unhelpful when it comes to compiling on other systems. You can also tell it to output a .mak file as well. I have a solution that has several build targets some that use cl, some that use gcc, each time I hit build solution on the gcc one it generates a .mak file.
|
# ? Sep 23, 2011 14:38 |
|
As much fun as it is to bash Microsoft, Visual Studio is a great IDE and the compiler is also very compliant (all compilers have issues, yes, even gcc, though clang is pretty awesome). People still have a sour taste in their mouth from VC++ 6, which was in development before the first C++ standard was even ratified in 1998 and it's gotten to the point that people don't even remember why they hate it anymore. True, VC++ still does have some non-compliant extensions, but for the most part, everyday compliant code will compile. Unless you are doing advanced stuff with templates or non-trivial stuff with the preprocessor, neither of which most people do, you generally won't have problems. Even there, VC++ can handle most modern template metaprograms without a hitch. This is coming from someone who does lots of crazy template stuff -- VC++ is not a bad compiler and Visual Studio is a good IDE. Also, as was pointed out, you can export makefiles.
|
# ? Sep 23, 2011 16:52 |
|
It's pretty rare to run into non-standard stuff when using the Visual C++ compiler. The Visual C++ runtime is another matter, because it doesn't include stuff from C99 which you do get using libc on most other platforms. So you run into issues like needing to use _snprintf, etc. When it comes to C++ though, their standard library is very compliant. And the IDE is the best IDE. As far as cross-platform build systems I would look into CMake, which can generate both makefiles and Visual C++ project/solution files from your source CMakeLists.txt file. At work we use CMake to build projects that target about a dozen different platforms, and it's a godsend compared to what we used to do.
|
# ? Sep 23, 2011 21:46 |
|
nielsm posted:FYI, just using the Visual C++ IDE does not magically make your code become non-standard. There's two ways VC++ can make you write weird code: MFC and C++/CLR (C++ for .NET). With the Win8 Developer Preview there's also a third, C++/CX. But it's not like it writes weird code behind your back, unless you actually tell it to create a project using any of those variations. Programs are like water and will naturally expand to fill their API container. If you're writing your code in Visual Studio (or anywhere, really, but Visual Studio stands out) and not taking specific steps to stay cross-platform/ANSI, you're deluding yourself if you think you're writing cross-platform/ANSI code. That said, worry about writing portable C++ once you know how to write C++ in the first place, and Visual Studio has a really sweet help system.
|
# ? Sep 24, 2011 00:13 |
|
wellwhoopdedooo posted:and Visual Studio has a really sweet help system. I guess the new help system is still good compared to the nothing that most other IDEs offer, but I really miss the help system that was borderline effortless. (I kept using that one past two major version iterations because the help system was just that much better.) NOSTALGIA.
|
# ? Sep 24, 2011 01:00 |
|
roomforthetuna posted:I liked the help system from way back in 1998 when it was called "Developer Studio", when it used .hlp file behavior instead of compiled html. It meant generated indexes and searches that were both faster and more helpful than the newer help system - I could pretty much always type a single word and get exactly what I wanted out of it. The new one takes a while and then insists on trying to spew MFC and Visual Basic junk at me half the time (I don't even have VB or MFC stuff installed). Oh, yeah, actually using the help system is a loving nightmare. But, it's really, really thorough, at least compared to anything else I've ever seen, and the examples (something most other documentation practically ignores) are invaluable to learning.
|
# ? Sep 24, 2011 01:12 |
|
I'm really curious what kinds of help topics generate results for both MFC and Visual Basic.
|
# ? Sep 24, 2011 01:20 |
|
Paniolo posted:I'm really curious what kinds of help topics generate results for both MFC and Visual Basic. I think the old help files had a lot of manual index entries, like a book written by actual human beings for human beings, so when you searched for stuff it would have a much better chance of taking you to the stuff you're looking for. I'd still use the old Win32 SDK hlp file if I could, when working with Win32, but we're not even allowed to open hlp files any more, with modern Windows.
|
# ? Sep 24, 2011 01:39 |
|
Oh, I understand now - you're hitting F1 for help? Yeah, that doesn't work at all. MS generally has excellent documentation but you're better off using Google to get to it. Alternately if you install the Windows SDK it comes with the kind of self-contained help file you're looking for, as does DirectX. Doesn't integrate into VS, though, at least I haven't been able to get it to. Paniolo fucked around with this message at 02:29 on Sep 24, 2011 |
# ? Sep 24, 2011 02:26 |
|
Paniolo posted:Oh, I understand now - you're hitting F1 for help? Yeah, that doesn't work at all. MS generally has excellent documentation but you're better off using Google to get to it. Alternately if you install the Windows SDK it comes with the kind of self-contained help file you're looking for, as does DirectX. Doesn't integrate into VS, though, at least I haven't been able to get it to. The new self-contained help files, as with DirectX's, are also what I'm grumbling about, because they are the compiled HTML format, which is the one where most of the 'search' stuff is auto-generated and thus dumb. (Though the auto-generated part of old help file indexes was better too! But it was twice as betterer for being combined with a human-influenced index.) But yes, it's also true that if you want to use MSDN at all then only Google works. I found it pretty funny last time I tried it that Microsoft's own search engine didn't have the page I wanted in its entire first page of results, even though it was limited to searching only within MSDN, whereas Google had the page I wanted (from MSDN) as the second result from a dataset comprising everything on the web. Edit: To be fair, the DirectX help file isn't actually too bad, it's certainly not nearly as sickening as the VC++ built in doc search. But it's also not nearly as amazingly helpful as the historical Win32 SDK help file. roomforthetuna fucked around with this message at 04:11 on Sep 24, 2011 |
# ? Sep 24, 2011 04:09 |
|
MSDN has the annoying habit of listing the Windows CE page first, instead of the actual result you want.
|
# ? Sep 24, 2011 04:29 |
|
How come stream operators don't have covariant return types? code:
|
# ? Sep 27, 2011 00:21 |
tractor fanatic posted:How come stream operators don't have covariant return types? Virtual-ness is my guess. If stringstream::operator<< was to return a stringstream& then it couldn't implement the ostream::operator<< which (for hopefully obvious reasons) must return ostream&. They also can't both exist at the same time because you can't overload on return type alone.
|
|
# ? Sep 27, 2011 00:31 |
|
Wouldn't that just be a covariant return type? stringstream (I assume) derives from ostream so a function that returns stringstream& can override a function that returns ostream&.
|
# ? Sep 27, 2011 00:37 |
|
I've seen it compile on some platforms and not compile on others.
|
# ? Sep 27, 2011 04:25 |
|
The deal is that operator<< is not necessarily specified directly on stringstream, so what you're actually asking for is a language feature that says the function returns the same type as its first argument. That's not actually reasonable to implement given multiple inheritance. n.b. I haven't actually checked the library standard about this.
|
# ? Sep 27, 2011 06:39 |
|
nielsm posted:Virtual-ness is my guess. As usual, rjmccall is right about the stream operators not being specified directly on stringstream; they're defined in basic_istream and basic_ostream.
|
# ? Sep 27, 2011 07:17 |
|
Platform-specific fun stuff: It looks like if you allocate memory using "new", then Visual C++'s debugger will break it down as the type it was allocated as even if referenced through a parent type or void pointer. However, if it was created using a custom allocator (i.e. placement new), it only shows as the type of the pointer you're looking at. Anyone know if there's a mechanism for producing the type-aware behavior with a custom allocator? OneEightHundred fucked around with this message at 21:34 on Sep 27, 2011 |
# ? Sep 27, 2011 21:31 |
|
OneEightHundred posted:Platform-specific fun stuff: It looks like if you allocate memory using "new", then Visual C++'s debugger will break it down as the type it was allocated as even if referenced through a parent type or void pointer. However, if it was created using a custom allocator (i.e. placement new), it only shows as the type of the pointer you're looking at. VS can only do this if your class has a v-table, because that's what it uses to determine the type at run-time. It should work no matter where the memory is or how it was allocated as long as it does. Edit: I just threw together a quick test and verified this myself in VC++ Express 2010; code:
The1ManMoshPit fucked around with this message at 02:45 on Sep 28, 2011 |
# ? Sep 28, 2011 02:41 |
|
The1ManMoshPit posted:VS can only do this if your class has a v-table, because that's what it uses to determine the type at run-time. It should work no matter where the memory is or how it was allocated as long as it does. Shouldn't it also be able to do it if RTTI is enabled?
|
# ? Sep 28, 2011 04:30 |
|
litghost posted:Shouldn't it also be able to do it if RTTI is enabled? RTTI only works for classes with a vtable.
|
# ? Sep 28, 2011 04:31 |
|
Paniolo posted:RTTI only works for classes with a vtable. Didn't know that. It is interesting that GCC for example doesn't warn about this (using typeid on a type without a vtable).
|
# ? Sep 28, 2011 04:38 |
|
Types without a vtable can only possibly be one type which is known at compile time.
|
# ? Sep 28, 2011 04:58 |
|
I'm rewriting a module for a c/c++ project (most of the files are c, at least the ones I am in charge of), and the shortcomings in my education are taking their toll... I had just written up a couple of paragraphs, but it was getting so convoluted that I scrapped it. I'm dealing with a preemptive real time operating system on an ARM processor, and I'm having concerns about concurrency issues between three different threads and an asynchronous interrupt routine that vomits data at one thread whenever it pleases. Does anyone have any good reading on this subject matter, whether online or in textbook form?
|
# ? Sep 28, 2011 19:49 |
|
pseudorandom name posted:Types without a vtable can only possibly be one type which is known at compile time.
|
# ? Sep 28, 2011 20:28 |
|
OneEightHundred posted:I'm pretty sure this isn't true, you just wind up getting a vptr after the vptr-less parent class's properties. Are you talking about adding virtual methods to a class when none of the base classes have vtables? I don't think that's what pseudorandom name is talking about, but anyway. All the major C++ ABIs will arrange class layout so that, if the class has any virtual method tables, one such table will appear at offset zero. Therefore, if you have a non-virtual base with no vtable, and you need a vtable, the base will always be allocated at a non-zero offset. Similarly, if your first declared non-virtual base has no vtable but your second non-virtual base does, the second base class will be at offset zero. This is true even in vfptr/vbptr ABIs like MSVC, although it gets a little more complicated.
|
# ? Sep 28, 2011 21:39 |
Nevermind
Popete fucked around with this message at 06:00 on Sep 29, 2011 |
|
# ? Sep 29, 2011 05:44 |
|
How well does Visual Studio .NET 2010 handle native C++ code these days? I heard you have to go through some hoops to make it poop out native code. I am developing on Linux with Eclipse, but I'm tempting the thought of transitioning, since I can get a license easily (and legit) enough. But I don't want to doodle around in it and find it's not particularly better. As an IDE, I'm trying to find something that does a better job calling me out on my bullshit before I spend a few minutes compiling. I am also hoping its build time is faster. Speaking of build times, is it worth it perhaps to just so up the build environment on a ram disk or something? My computer is going on 5 years old and I'm thinking of upgrading, but meanwhile I have 8GB of RAM that I don't fully use when developing. I was thinking of making a 1GB ram disk. Is there something in Eclipse to encourage it to use that space for building and debug running? Is the copy transfer time worth it? Slanderer posted:I had just written up a couple of paragraphs, but it was getting so convoluted that I scrapped it. I'm dealing with a preemptive real time operating system on an ARM processor, and I'm having concerns about concurrency issues between three different threads and an asynchronous interrupt routine that vomits data at one thread whenever it pleases. Does anyone have any good reading on this subject matter, whether online or in textbook form? If you've had some background with concurrency then I wouldn't bother looking up concurrency generally. Instead, go with the library documentation for whatever you are using. Look up how it handles locks in the documentation and how people are doing it online. Then similarly check how the documentation demonstrates waiting and notification, and similarly look online at how people do it. You'll probably find people bitching about something in the library and there might be a known issue or limitation. Step back from the main work you're trying to do and just get some producer-consumer stuff working to your satisfaction. I used to think producer-consumer was particularly dry but it has represented most of the concurrency situations I've had. You're talking about three threads, so maybe it doesn't make sense in its simplest form but maybe it does whatever you're doing.
|
# ? Sep 29, 2011 17:39 |
|
Rocko Bonaparte posted:I heard you have to go through some hoops to make it poop out native code.
|
# ? Sep 29, 2011 17:46 |
|
Rocko Bonaparte posted:Speaking of build times, is it worth it perhaps to just so up the build environment on a ram disk or something? My computer is going on 5 years old and I'm thinking of upgrading, but meanwhile I have 8GB of RAM that I don't fully use when developing. I was thinking of making a 1GB ram disk. Is there something in Eclipse to encourage it to use that space for building and debug running? Is the copy transfer time worth it? I imagine debug building the object files to a ramdisk would be a worthwhile timesaving if you have that much spare RAM, but I doubt copying all the source files to a ramdisk would be (the pain in the rear end getting it set up right alone would offset any gains).
|
# ? Sep 29, 2011 18:24 |
|
Putting intermediate files on a ram disk can make linking a lot faster, but compiling is usually CPU-bound.
|
# ? Sep 29, 2011 19:28 |
|
I'm trying to teach myself C/C++ coming from Java, could somebody look over my implementation of a singly-linked list? I've tested it a little and it seems to work. http://pastebin.com/WGhEiH0L Some things I'd like to know are: - are there errors/memory leaks I can't see? - how is my style? - this is in C++, how much harder would it be to do this in C (using calloc instead of new and so on) - how would I store data of an arbitrary type? Void pointers?
|
# ? Sep 29, 2011 20:03 |
|
AlsoD posted:- are there errors/memory leaks I can't see? I'd also say that stylistically that function is a bit bad, in that it doesn't inform you if it fails to insert (index out of bounds), and if you call it on an empty list it adds the element regardless of what index you gave (ie. index out of bounds prevents insertion sometimes but not other times. Inconsistent function behavior is not good). The lazy fix for that would be to make it so any index out of bounds means you just append - that way you don't need to return errors, and it's not an entirely unreasonable behavior. quote:- this is in C++, how much harder would it be to do this in C (using calloc instead of new and so on) quote:- how would I store data of an arbitrary type? Void pointers? Edit: Also, I could be mistaken but it looks like your 'get' function has the return value backwards - if your decrementing index has not run out (reaching -1) then you have a valid pointer, but you have it returning 0 if it's not run out, and the pointer if it has run out. You don't even need to do that check, since your 'temp' pointer will be zero (the value of a null pointer) anyway if it reaches the end of the list. (Line 64.) roomforthetuna fucked around with this message at 20:40 on Sep 29, 2011 |
# ? Sep 29, 2011 20:33 |
|
Plorkyeran posted:Putting intermediate files on a ram disk can make linking a lot faster, but compiling is usually CPU-bound. Links can strain CPU/RAM as well if you're using link-time code generation.
|
# ? Sep 29, 2011 21:46 |
|
AlsoD posted:
|
# ? Sep 29, 2011 23:07 |
|
code:
I can see that object in this memory spot is a a vector filled with my desired values, but for some reason the deconstructor is giving me problems. I've tried to make sure I'm using the correct syntax by researching online, and it seems as if I am. Any ideas on how to solve this? Jort fucked around with this message at 19:25 on Sep 30, 2011 |
# ? Sep 30, 2011 19:21 |
|
You might be copying the full object when doing something, in the process copying the contents pointer and causing a double-free when the destination dies.
|
# ? Sep 30, 2011 19:36 |
|
|
# ? Jun 8, 2024 05:50 |
|
Ok, so it looks like it's trying to free the "this" pointer. How would I go about dealing with this double creation? I'm using a copy constructorcode:
|
# ? Sep 30, 2011 19:48 |