|
User0015 posted:Bar.h - added "friend class Foo". It compiled. Doesn't work, but it compiled. That's always a good start. What would you expect it to do other than compile? Your main function doesn't do anything. (Also I am very surprised that compiles.)
|
# ? Aug 11, 2009 23:51 |
|
|
# ? Jun 10, 2024 08:04 |
|
Avenging Dentist posted:What would you expect it to do other than compile? Your main function doesn't do anything. (Also I am very surprised that compiles.) Execute Barworks() and print text to the screen? (I added some lines to main to call Foowork) Also, me too. If you have some better ways to do this, I'm all ears. edit - It works. Somehow. User0015 fucked around with this message at 23:58 on Aug 11, 2009 |
# ? Aug 11, 2009 23:55 |
|
I am hoping you made Barworks public, or you have a very strange compiler.
|
# ? Aug 12, 2009 00:00 |
|
That's a good question. Lets see... User0015 fucked around with this message at 00:17 on Aug 12, 2009 |
# ? Aug 12, 2009 00:10 |
|
Yes. Structs default to public.
|
# ? Aug 12, 2009 00:21 |
|
Hello, I need more help. I am writing a C++ program in VS 2008 that runs a piece of hardware so it has its own libraries and other stuff that it accesses. I am also using Boost.asio for this program. It's based on two separate programs that both run in VS just fine. When I try to compile, I get these errors: code:
|
# ? Aug 12, 2009 23:39 |
|
You may have seen this terrible horrible code. Help me learn how to make it better (more horrible).code:
code:
The reason is because in numeral_fop I advance the iterator to next and dereference to get the next character in the sequence. I use this information to determine if I should add the current value to the total, or subtract it from the total. However when the iterator is at the end of the sequence, I am advancing past the end of the sequence and dereferencing. This seems like a bad thing. I have the feeling like the code only coincidentally works. I looked over the Boost.MPL documentation a bit and it seems like I could be using eval_if maybe somehow to avoid dereferencing an iterator past the end of the sequence. But I've tried and I can't seem to figure out how. I get the same error. Then I thought maybe I could use enable_if somehow. I'd have two versions of numeral_fop, one for when the iterator isn't at the end and another when it is. But again my skills were lacking and I just couldn't figure out how to get it to work like I wanted. The best solution I could imagine would be to somehow iter_fold over [begin, end), but iter_fold doesn't seem to be configurable like that. It iterates over [begin, end] and that's that. Can any of the boost users here come up with something to solve this? Lexical Unit fucked around with this message at 00:24 on Aug 13, 2009 |
# ? Aug 13, 2009 00:21 |
|
This is hardly elegant, but it seems to work. iter_fold already iterates over [begin, end), so one solution is to just delegate the iterator dereferencing to another metafunction that isn't instantiated unless it can operate on a valid next-iterator.code:
|
# ? Aug 13, 2009 02:30 |
|
HondaCivet posted:I'm guessing this is some weird compatibility issue because I of course did not write winnt.h and haven't seen anything like this before. What sorts of things would remedy this? Chances are, somewhere there's a line like this before you include winnt.h: code:
code:
EDIT: Also, if you do find out who did #define SHORT short, you should yell at them. Avenging Dentist fucked around with this message at 02:51 on Aug 13, 2009 |
# ? Aug 13, 2009 02:44 |
|
Oh, also regarding Lexical Unit's thing. I don't know why people get so into compile-time string parsing when no compiler supports the suffix operator yet. It always ends up being clumsy (in a bad way) and the suffix operator is going to eliminate a lot of the tedium of writing the entry point.
|
# ? Aug 13, 2009 02:50 |
|
The Red Baron posted:Also, in before TTS or AD post a 10x more elegant solution . Avenging Dentist posted:I don't know why people get so into compile-time string parsing when no compiler supports the suffix operator yet.
|
# ? Aug 13, 2009 03:22 |
|
Avenging Dentist posted:Oh, also regarding Lexical Unit's thing. I don't know why people get so into compile-time string parsing when no compiler supports the suffix operator yet. It always ends up being clumsy (in a bad way) and the suffix operator is going to eliminate a lot of the tedium of writing the entry point. s:concepts:suffix operator:
|
# ? Aug 13, 2009 06:13 |
|
Fecotourist posted:s:concepts:suffix operator: Hm yase a less-than-one page subsection is basically the same as a 22-page section, you got me there!
|
# ? Aug 13, 2009 06:19 |
|
Fecotourist posted:s:concepts:suffix operator: If you're going to make a nerdy substitution joke the least you could do is get the order right.
|
# ? Aug 13, 2009 07:46 |
|
floWenoL posted:If you're going to make a nerdy substitution joke the least you could do is get the order right. Way to get it! His post read as if it were written by AD passed through sed -e 's:concepts:suffix operator:g'. I.e. a variation on the standard (hah!) fetish. I just hope all this wonder ends up being C++1x and not 2x. Edit: Malformed sed command! Fecotourist fucked around with this message at 16:56 on Aug 13, 2009 |
# ? Aug 13, 2009 15:16 |
|
Can someone (*cough*) show me how to build up an AST (my own data structures) using spirit? I've only ever used ANTLR as a parser generator which lets you return whatever you want as a result of parse rules, but spirit doesn't exactly do the same thing. So how about this grammar: code:
Using this AST: code:
|
# ? Aug 13, 2009 19:01 |
|
I really don't think you're doing that right at all. You should probably be looking at the documentation since the AST example is exactly what you're trying to do: http://www.boost.org/doc/libs/1_39_0/libs/spirit/classic/doc/trees.html
|
# ? Aug 13, 2009 19:19 |
|
I guess I wanted to see if there was a way to use spirit without having to traverse their tree. Edit: Went through the example, and I successfully modified it to spit out my AST. I'll start moving on to bigger and better parsers now. Thanks. Contero fucked around with this message at 22:10 on Aug 13, 2009 |
# ? Aug 13, 2009 20:09 |
|
For your own sake, please look into Spirit2.1 instead. The attribute-based parsing is leaps and bounds better to work with than the old AST construction (which was apparently kinda hacked on in the first place)
|
# ? Aug 13, 2009 22:39 |
|
I just spent several hours documenting some old binary files. I've got two variants of an old C program that should read them (old as in written in K&R C, last updated in 1992). Neither work because they assume the width of ints, shorts and so forth that are not valid with my machine. I am updating the program to C99 so I can use the fixed-width types from stdint.h to avoid this issue, but that only works for integral types. The problem is I've also got floats and doubles in this binary file (in IEEE format). I can't seem to find an equivalent to fixed-width types for floating points types or even a way to specify IEEE format. Since I don't want to have to mess with this program ever again, is there some way that I can read the data and put it into whatever underlying floating point format the particular compiler is using that has a reasonable chance of just working in the future with at most a recompile? Endianness shouldn't be a problem since I can detect it based on this particular file format (Except for some pathological counter examples but realistically those won't occur). 6174 fucked around with this message at 07:05 on Aug 14, 2009 |
# ? Aug 14, 2009 06:56 |
|
I was kind of excited to try spirit 2.1 out, but after messing around with it for two hours I honestly find it to be much more cryptic and less easy to use than classic spirit. It also takes forever to compile. Also walking the classic tree manually lets me use whatever code I want to construct a return value. I don't have to stuff it all into bits of lazy evaluated code sprinkled throughout the grammar.
|
# ? Aug 14, 2009 07:10 |
|
Contero posted:It also takes forever to compile. Better than taking forever to run. Spirit Classic is unbelievably slow on some stuff.
|
# ? Aug 14, 2009 07:42 |
|
6174 posted:The problem is I've also got floats and doubles in this binary file (in IEEE format). I can't seem to find an equivalent to fixed-width types for floating points types or even a way to specify IEEE format. That's because the underlying format for floating point types is not defined by the ISO standard.
|
# ? Aug 14, 2009 07:46 |
|
Avenging Dentist posted:That's because the underlying format for floating point types is not defined by the ISO standard. I realize that. It also doesn't specify the underlying format for the five standard signed integer types, but there are also the intN_T / uintN_t types where it is specified. My problem is I can't find something corresponding to intN_t for floating point values (which may be because they don't exist).
|
# ? Aug 14, 2009 07:58 |
|
6174 posted:I realize that. It also doesn't specify the underlying format for the five standard signed integer types, but there are also the intN_T / uintN_t types where it is specified. My problem is I can't find something corresponding to intN_t for floating point values (which may be because they don't exist). code:
Also keep in mind that intN_t and uintN_t are not mandated by the standard. Avenging Dentist fucked around with this message at 08:18 on Aug 14, 2009 |
# ? Aug 14, 2009 08:10 |
|
Avenging Dentist posted:See also Annex F of ISO/IEC 9899:1999. That is what I get for not reading the Annexes. This should be plenty good enough for what I need. Though crazily enough there is yet another variant of this same program that does convert the IEEE values in the file to Cray floating point. Avenging Dentist posted:Also keep in mind that intN_t and uintN_t are not mandated by the standard. The main thing I'd like is for it to just work with at most a recompile, but if that can't occur failing in a way that is obvious that the build environment is crazy should be good enough.
|
# ? Aug 14, 2009 08:31 |
|
Avenging Dentist posted:Chances are, somewhere there's a line like this before you include winnt.h: A few problems with this unfortunately . . . 1. For some reason the "go to definition" thing is greyed out whenever I try it on something, not even just shorts. 2. I searched the whole project and "#define SHORT short" never comes up. Unsigned short stuff comes up but that wouldn't count right? halp
|
# ? Aug 14, 2009 16:07 |
|
HondaCivet posted:1. For some reason the "go to definition" thing is greyed out whenever I try it on something, not even just shorts. Intellisense sucks sometimes. It can help if you delete the .ncb file from the project dir and then rebuild the project. HondaCivet posted:2. I searched the whole project and "#define SHORT short" never comes up. Unsigned short stuff comes up but that wouldn't count right? The easy solution is code:
|
# ? Aug 14, 2009 17:33 |
|
Avenging Dentist posted:Intellisense sucks sometimes. It can help if you delete the .ncb file from the project dir and then rebuild the project. Where should that code go? I tried in main, above where the other #includes are, in a header . . . it either doesn't do anything or makes a billion other errors pop up instead.
|
# ? Aug 14, 2009 18:01 |
|
HondaCivet posted:Where should that code go? I tried in main, above where the other #includes are, in a header . . . it either doesn't do anything or makes a billion other errors pop up instead. What are some of the other errors? You could also try putting #include <windows.h> before any other #includes. You might want to put #define NOMINMAX before that since Windows is retarded.
|
# ? Aug 14, 2009 18:21 |
|
Avenging Dentist posted:Also keep in mind that intN_t and uintN_t are not mandated by the standard. They are if you have integral types which can fit the requirements, which most implementations will.
|
# ? Aug 15, 2009 09:07 |
|
ctz posted:They are if you have integral types which can fit the requirements, which most implementations will. Yes congratulations you win the prize.
|
# ? Aug 15, 2009 09:49 |
|
So I'm messing around with Irrlicht, using code::blocks and compiling with the MS Visual C++ toolkit. I have iostream.h and fstream.h, but for the life of me I can't get it to let me open, read or write to a text file. ofstream fout("name.txt"); fout << yourname; fout << flush; fout.close(); This kind of stuff just doesn't work. Last time I used Irrlicht I used the GCC compiler, and originally I cut my C++ teeth with borland, so doing anything in MS visual C++ is kinda confusing to me. Also can someone explain to me why I can't just use cout, but instead have to use std::cout?
|
# ? Aug 16, 2009 05:23 |
|
Someone hasn't used c++ since the standard got made
|
# ? Aug 16, 2009 05:29 |
|
MSVC still has iostream.h???
|
# ? Aug 16, 2009 05:40 |
|
Avenging Dentist posted:MSVC still has iostream.h??? So does gcc, but at least the latter is kind enough to inform you you're using a deprecated header
|
# ? Aug 16, 2009 06:09 |
|
jonus posted:So I'm messing around with Irrlicht, using code::blocks and compiling with the MS Visual C++ toolkit. I have iostream.h and fstream.h, but for the life of me I can't get it to let me open, read or write to a text file. std:: is a namespace, you can add using namespace std; at the top and you won't need the std:: in front of every cout. (pretty sure) also, in VS you should use #include <iostream> and #include <fstream> with no .h the ones with .h are old bad headers that suck, same games for most headers I think... like string.h is just string etc
|
# ? Aug 16, 2009 07:19 |
|
Otto Skorzeny posted:So does gcc, but at least the latter is kind enough to inform you you're using a deprecated header The got rid of them over a year ago for 4.3.0's release.
|
# ? Aug 16, 2009 07:30 |
|
Avenging Dentist posted:MSVC still has iostream.h??? I know 2008 does not, and I think it's been thrown away in 2005 as well.
|
# ? Aug 16, 2009 07:54 |
|
|
# ? Jun 10, 2024 08:04 |
|
Sweeper posted:like string.h is just string etc Hahahahahahahahaha no. These two headers have nothing to do with one another. (string.h is cstring in C++)
|
# ? Aug 16, 2009 09:47 |