|
//This program calculates the area of a circle. It asks the user //if he or she wishes to continue. A loop that demonstrates the //toupper function repeats until the user enters 'y' or 'Y', //'n' or 'N'. code:
Should I be using another compiler? VV Thanks. That did the trick. Sephiroth_IRA fucked around with this message at 14:34 on Aug 24, 2011 |
# ? Aug 24, 2011 14:22 |
|
|
# ? May 19, 2024 00:26 |
|
Just get Visual Studio express edition. As far as your error, check the line where you're including the ctype header. You have an extra ""<". Also, in the future, try posting your code with the "code" tags, so that indentation is preserved.
|
# ? Aug 24, 2011 14:26 |
|
Orange_Lazarus posted:I'm using DevC++ quote:
Just to be pedantic: DevC++ is not a compiler -- It's an IDE that integrates the MinGW version of GCC (the Gnu Compiler) and GDB (the Gnu Debugger) with a text editor. It also completely sucks. There's nothing wrong with GCC itself though.
|
# ? Aug 24, 2011 16:14 |
|
I'm using a large library (CImg (cimg.sf.net)) which is entirely templated. Because I'm building a library, which uses the CImg library, any user of my library has to also include the CImg.h header file, which makes compilation time very long. Since I'm only interested in using CImg with a specific template parameter (unsigned char) is there a way to pre-compile it, and then not have any users of my library have to also include the CImg header file? Thus vastly speeding up the compilation time for all of my users?
|
# ? Aug 24, 2011 16:17 |
|
In theory, you can just copy code at will out of the CImg header files into one of your own. If you can isolate the parts that you need, that is. You may run into license issues though if you release this to the public, since I would guess it counts as modifying CImg.h: http://cimg.sourceforge.net/reference/group__cimg__faq.html#ssf15
|
# ? Aug 24, 2011 17:22 |
|
Harokey posted:I'm using a large library (CImg (cimg.sf.net)) which is entirely templated. Because I'm building a library, which uses the CImg library, any user of my library has to also include the CImg.h header file, which makes compilation time very long. Since I'm only interested in using CImg with a specific template parameter (unsigned char) is there a way to pre-compile it, and then not have any users of my library have to also include the CImg header file? Thus vastly speeding up the compilation time for all of my users? code:
code:
Another way you might be able to do it is to make the shared class simpler than the one you actually use, something like: code:
code:
Another feature of this way is that if you make all the library functions virtual (pure virtual in the exposed version) then the only things you need to export from the library, when it's done as a DLL, are the Make/Destroy functions. Both these ways are kind of hideous though, maybe someone else has a better way. And it's no use at all if you need to directly expose CImg methods or values to the user. roomforthetuna fucked around with this message at 17:33 on Aug 24, 2011 |
# ? Aug 24, 2011 17:24 |
|
We have an application that's been working in production for about 15 years. It's just under 200k lines of code, written in C++, and uses MFC extensively. The original developers are still around, and are still maintaining it, but they're not getting any younger. Finding fresh young talent that is willing to learn MFC is hard. Without saying much other than the UI needs to be fast/responsive, as there are lots of progress bars and labels being updated in real-time from hardware (scales and sensors and such), what are some options for an MFC-exit-strategy? Due to the real-time nature of the program, I tend to believe that moving to .NET is not an option.
|
# ? Aug 24, 2011 19:34 |
|
epswing posted:We have an application that's been working in production for about 15 years. It's just under 200k lines of code, written in C++, and uses MFC extensively. There are plenty of reasons not to use .NET, but it is possible to create a real time UI using it. The application I wrote is written in c#/WPF and is able to display 100s of audio meters and values along with real time FFT and RTA displays at 30fps.
|
# ? Aug 24, 2011 20:17 |
|
Thanks fankey, I'll take a closer look at Qt. I wasn't clear enough earlier, the need for real-time is primarily in the core of the program, and having the UI update fast enough is almost as essential. One of the program's responsibilities is to dump tens of thousands of kilograms of material at hundreds of kilos per second onto a scale, by controlling the open/close gates that the material is flowing through. Now multiply that by maybe 10 materials/gates dumping simultaneously. If we're a few dozen milliseconds late (because the managed code decided it was time to GC something large), that might mean an extra 50 kilos sitting on a scale that someone needs to "account for" (read: get a shovel), which isn't good for anyone involved. Eventually I'll put together a simulation in .NET to see if it can handle our requirements, but for the foreseeable future it looks like we're sticking to C++.
|
# ? Aug 24, 2011 20:31 |
|
epswing posted:Thanks fankey, I'll take a closer look at Qt.
|
# ? Aug 24, 2011 20:43 |
|
I've only used Qt from python but it really is a nice framework. Keep in mind your GUI at least would probably need to use the Qt build system - qmake.
|
# ? Aug 24, 2011 23:06 |
|
epswing posted:Thanks fankey, I'll take a closer look at Qt. The responsiveness of your GUI code shouldn't have any bearing on the responsiveness of your control code (unless your flow is being stopped by a button click or UI timer in which case good luck ) I'd second the suggestion of keeping the core in C++ and wrapping a .NET GUI around it either with C++/CLI or exporting functions from C++ and P/Invoking.
|
# ? Aug 24, 2011 23:47 |
|
csammis posted:The responsiveness of your GUI code shouldn't have any bearing on the responsiveness of your control code (unless your flow is being stopped by a button click or UI timer in which case good luck ) I'd second the suggestion of keeping the core in C++ and wrapping a .NET GUI around it either with C++/CLI or exporting functions from C++ and P/Invoking. The responsiveness of the UI is for the sake of the operators, they like to see a pretty accurate representation of what's happening. The question is how can we shake off MFC. Wrapping a .NET UI around a C++ core sounds verrry interesting... Thanks!
|
# ? Aug 24, 2011 23:57 |
|
roomforthetuna posted:Both these ways are kind of hideous though, maybe someone else has a better way. I'm not sure why you think your second idea is hideous. As long as "MyLibrary" is abstract, he would just have to do the usual OO subclass flim-flam, no need to cast "this" to anything. Third alternative: Forward-declare the CImg template and use opaque pointers to the specialization code:
|
# ? Aug 25, 2011 00:10 |
|
Mustach posted:I'm not sure why you think your second idea is hideous. As long as "MyLibrary" is abstract, he would just have to do the usual OO subclass flim-flam, no need to cast "this" to anything.
|
# ? Aug 25, 2011 01:00 |
|
roomforthetuna posted:Not exactly what you're asking for, but if your users aren't using the CImg library directly through yours then there are a couple of ways you can 'hide' CImg from your interface - you can either make your contained CImg a pointer which you forward-declare in the shared header and then define properly in your own code, I guess what I'm trying to say is I'd like to still expose the CImg library, but remove the template portion of it. Functionally change it so that there's a header & cpp file, but remove the templated aspect and just fix it as "unsigned char" although now that I'm typing this there doesn't really seem to be a way to do this rather than actually going through and doing exactly what I said by hand (Or writing some script to essentially do the same thing.)
|
# ? Aug 25, 2011 01:51 |
Your best bet is probably then just to tell people to figure out how to use Precompiled Headers with their compiler of choice. It's designed exactly for cases like this.
|
|
# ? Aug 25, 2011 01:57 |
|
I have a question that I know multiple ways to solve, but I'd like to get some input from other people. I have a file format, all UTF-8 text, that contains series of records. I only need forward read access, and I'd like to take the records in the file and translate them to appropriate objects. There are many different record types in the file, with different types of fields, all depending on a record type identifier. There's a little bit of trickery that has to do with continuing records if the last character is a '1' or marking the end of a record if the last character is '0'. Depending on the type of field the field of the record either wraps and continues to the next line, or the count is restarted and the field's character count restarts on the next line. Either way, that's not important. Prefixed on every record type is a 2 character identifier, so that you know how to parse the record. What I have is currently a class that works as a helper to parsing the record. It gives you the ability to do things like "what is the record identifier code for this?" or "give me the next field, it should be 15 characters (not bytes, since this is UTF-8)" and works like an iterator on the lines of the record. This class is used to simplify the interpretation logic of the records. My goal is to make this easily extensible, while the general format of the data doesn't change (2 characters prefix the record for the type, all lines are 80 characters long, the last character marks continuation or termination of the record), the types of records and the type of data they can contain can change with each release. My current idea for the approach is to have a Document class that provides a few simple methods: the ability to register a "creator" function for each record type. This allows you to provide the method to be used that parses the record contents and translates them into objects, all of which will sub-class the Record class. I'm assuming that the Record class will basically only have a "record type" property, and the sub-classes of Record will contain all the type-specific elements. Then the Document class can provide an iterator that will traverse the file in a forward-read fashion and return a Record object that is created by the registered creator functions. What this leaves me, though, is that when I move the iterator forward in a loop fetching all the records, I'm going to have to do a static_cast<> on the Record instances depending on the record type. I don't have anything against this, but I'm not sure if this is the best approach. Is this my best bet or is there a pattern I'm missing here?
|
# ? Aug 25, 2011 21:27 |
|
CRIP EATIN BREAD posted:What this leaves me, though, is that when I move the iterator forward in a loop fetching all the records, I'm going to have to do a static_cast<> on the Record instances depending on the record type. I don't have anything against this, but I'm not sure if this is the best approach. The idea as a whole sounds fine, but I don't understand why you have to do this... What do you want to do with each record that means you need to explicitly cast it to whatever type it is?
|
# ? Aug 25, 2011 21:44 |
|
CRIP EATIN BREAD posted:Is this my best bet or is there a pattern I'm missing here? The visitor pattern.
|
# ? Aug 25, 2011 21:44 |
|
Gerblyn posted:The idea as a whole sounds fine, but I don't understand why you have to do this... What do you want to do with each record that means you need to explicitly cast it to whatever type it is? This is geospatial data, and the records can represent any (and more) of the following: a segment, a point, a navigable feature, a node. A segment has 2 nodes, a length, what type of vehicles can traverse it. A node has a point. A point has an x and y value. They are so different that the logic used to process them is entirely different, and how they are used are entirely different. shrughes posted:The visitor pattern. Ok, I knew I was forgetting something. This should simplify my code significantly. CRIP EATIN BREAD fucked around with this message at 21:52 on Aug 25, 2011 |
# ? Aug 25, 2011 21:48 |
|
It sounds like you're primarily interested in the data, so I say forgo OO for this and use a struct or a union of structs for the Record type. Visitor is a pain in the rear end in C++ and not worth the trouble.
|
# ? Aug 25, 2011 21:53 |
|
Mustach posted:Visitor is a pain in the rear end in C++ and not worth the trouble. Not really. Unions are a bigger pain in the rear end in the long run. Wait, are you seriously suggesting a union of structs in C++ and forgoing the ability to use non-POD types in the structs? GTFO. FWIW you could also use boost::variant and boost::static_visitor, which is less a pain in the rear end for some reasons, and more of a pain in the rear end because of the boost.
|
# ? Aug 25, 2011 22:00 |
|
When using Visual C++ and its IDE, is there a way to make a resource file properly act dependent on data files that it includes? It doesn't seem to be done automatically as it would be for #includes, and manual dependency setting only seems to be a thing at the project level, not the file level. It's pretty frustrating to update a dependent image file and then have it not changed when I test because I didn't explicitly rebuild the resources.
|
# ? Aug 25, 2011 22:01 |
|
Mustach posted:It sounds like you're primarily interested in the data, so I say forgo OO for this and use a struct or a union of structs for the Record type. Unfortunately, once I fetch the data, I have to do massive amounts of processing on it. Sure I could write everything in functions, but it makes the code a hell of a lot easier to read when you can do a line1.findIntersection(line2). I'm currently using this library as a helper to identifying data problems, but the current compiler that is used for the raw data to output our geospatial database is over 1.5 million lines of poorly written ANSI-C code. There's zero-extensibility since not only does it depend on a big-endian CPU, but it was also written by people who don't know how to write libraries and have multiple copy/pasted methods for doing the same thing all over the place.
|
# ? Aug 25, 2011 22:01 |
|
You could look at how the Java Scanner class handles a similar problem: 1. hasNextFoo() tells you if the next record is of a particular type 2. nextFoo() returns the next record if it is of a particular type, and fails otherwise. If you're having to do significant logic based on whether the next record is a line, a point, or whatever, then this seems like a reasonable solution.
|
# ? Aug 26, 2011 01:10 |
|
shrughes posted:Not really. Unions are a bigger pain in the rear end in the long run. CRIP EATIN BREAD posted:line1.findIntersection(line2). Well, I dunno. If you're really doing a massive amount of processing, and depending on the processing, going through two virtual calls per operation could hurt. And you might have to worry more about how you allocate the records. But that's up to you to discover, if you care about any of these things I'm assuming.
|
# ? Aug 26, 2011 02:01 |
|
Hmm actually maybe unions are better if they're just a bunch of small academic floating point values.
|
# ? Aug 26, 2011 03:10 |
|
Are there any significant downsides to using #pragma comment(lib, "butts.lib")? I've been using it for small classes which I re-use a lot (e.g. a class I wrote for managing Xbox 360 controller input). I know how to include the libraries through the project properties (using Visual Studio) but I'm a lazy bastard so I use the pragma alternative. I tried Google but from that all I could find was that apparently it makes troubleshooting linker errors a bitch. So basically am I an idiot for using this and should stop?
|
# ? Aug 26, 2011 03:29 |
CRIP EATIN BREAD: I wonder, is it really a requirement that all records in the file are put into the same list structure? Wouldn't it make more sense to have one list of all points, another of all lines etc., if they all reference each other by some ID or whatever? So when you read a point, you add it to the list of points. A node, add it to the list of nodes. A line, add it to the list of lines. You shouldn't need to deal with type polymorphism that way, neither class inheritance style nor union style. nielsm fucked around with this message at 03:33 on Aug 26, 2011 |
|
# ? Aug 26, 2011 03:30 |
|
Optimus Prime Ribs posted:Are there any significant downsides to using #pragma comment(lib, "butts.lib")? It's pretty convenient, especially when you add extra dependencies as Win32 loves to distribute itself across many libraries. The less time required to use MSVC's awful property sheets the better.
|
# ? Aug 26, 2011 04:02 |
|
MrMoo posted:It's pretty convenient, especially when you add extra dependencies as Win32 loves to distribute itself across many libraries. If you're using your own libraries and still working on them, it's better to have the library project in your 'solution' and use project dependencies because that way you can be sure things get built in the right order, and it'll semi-automatically be using the appropriate debug/nondebug/etc. version. That and "you'll have to do it a different way for different platforms" are the only arguments against for me, and you have to do it a different way for different platforms anyway. I didn't know there was #pragma comment(lib,"butts.lib") I've been using #pragma comment(linker,"/DEFAULTLIB:butts.lib")
|
# ? Aug 26, 2011 04:55 |
|
roomforthetuna posted:I didn't know there was #pragma comment(lib,"butts.lib") I've been using #pragma comment(linker,"/DEFAULTLIB:butts.lib") I didn't know there was a #pragma comment(linker, "/DEFAULTLIB:butts.lib"). Does anyone know the difference between the two? Or is it just syntactical? Thanks for the responses though.
|
# ? Aug 26, 2011 05:23 |
|
Libraries specified with /DEFAULTLIB are searched after libraries included directly and are disabled by /NODEFAULTLIB. It's only intended for the CRT libraries but it's perfectly safe to use for other stuff if you need that behavior for some reason.
|
# ? Aug 26, 2011 06:44 |
|
roomforthetuna posted:That's a good meaningful answer - it's good to use the #pragma for system and external libraries quote:Does anyone know the difference between the two? Or is it just syntactical?
|
# ? Aug 26, 2011 06:46 |
|
roomforthetuna posted:I didn't finish that thought - I particularly meant the #pragma is great for system and external libraries that another library depends on.
|
# ? Aug 26, 2011 12:19 |
|
Linux development always like to promote shared libraries though and so we probably have to wait for Clang to implement it.
|
# ? Aug 26, 2011 14:21 |
|
It's not just a compiler thing; it affects the entire tool chain and (probably) the object-file format, because the compiler needs to communicate somehow with the linker.
|
# ? Aug 26, 2011 17:46 |
|
Good thing we have really flexible object file formats.
|
# ? Aug 26, 2011 18:07 |
|
|
# ? May 19, 2024 00:26 |
|
Hi, I don't have a question for this thread, but I do have a somewhat embarrassing request. I began self-teaching myself how to program in C/C++/C# a bit more than two years ago and I've been working nearly full time since then setting up the foundations of my own software and game development company. I don't really have a social life on or offline aside from my wife and year old son, but neither of them know anything about programming or what it is I spend most of my time doing. I've found forums and chat rooms to be for the most part quite terrible for forming interest based relationships, so I'm now resorting to my last resort: explicitly and literally asking for someone to be my programming buddy Even though I don't have any professional experience or claim to be a good programmer, I can't stress enough how passionate I am about programming. I was afraid of learning how to program for a long time, but once I thrust myself into the thick of it, I developed an unquenchable desire to spend as much time on it as I could spare and began pursuing a career as an independent, self-employed software developer almost immediately. I've been for the most part on track since beginning this endeavor two years ago and have been quite regularly coding 100+ hour weeks. I estimate that I won't begin to make any money for another two years or so from now, but I am enjoying what I am doing so much that it doesn't bother me one bit So who am I looking for? Just an internet/IM buddy who very much enjoys programming too. I don't particularly care how skilled or experienced you are, just as long as you're open to talking about programming or whatever If you are interested, shoot me an email at sigvatr@gmail.com Cheers!
|
# ? Aug 27, 2011 01:25 |