• What are you working on? December 2011 Edition
    3,353 replies, posted
[QUOTE=bobthe2lol;33930574]Forgive the ignorance, but... what does it do?[/QUOTE] Instead of me having to do something wonky where I do [cpp] #if defined(_MSC_VER) #define BYTESWAP_16(X) _byteswap_ushort(X) #define BYTESWAP_32(X) _byteswap_ulong(X) #else #define BYTESWAP_16(X) ((X & 0xFF00) >> 8) | ((X & 0x00FF) << 8) #define BYTESWAP_32(X) __builtin_bswap #endif int32_t x = BYTESWAP_32(y); [/cpp] etc. etc. You instead get to do [cpp] int x = bitwise::swap(y); [/cpp] and you get the ability to have a static_assert (so if there's an error, it'll be where you called bitwise::swap, NOT where the macro is defined or where the generated code is placed), as well as type safety and the ability to effectively debug builtins if you so choose (I can change the always_inline to never inline and then step through a function if I need to) And above all, I don't have to use the preprocessor, except to define very small corner cases such as includes [i]OR[/i] the very small base number of traits that I setup to let me do this (i.e., knowing at compiler time if I'm using msvc which allows the proper selection of the templated function) [QUOTE=voodooattack;33930470]That's incredible.. You should clean it up, put it all in one bundle and submit it to boost.org if you can. I think boost needs something like this.[/QUOTE] Unfortunately, boost tries to focus on being as platform agnostic as possible, (and compiler agnostic). Considering I'm depending on C++11 features heavily, I don't think they'd be willing to take it. However the source is open on my github account (under the mgine repo. This is being used for some tinkering I'm doing with a possible 'strongly defined' content pipeline as the focus for an engine), so you're free to peruse and laugh at my love of template metaprogramming and unnecessary type traits :v:
[QUOTE=i300;33930689]The UI is a [B]lot[/B] better on this one. Nice and simple, though the slider could use a bit of styling. Now you art sort of pushing the limit. Supporting [I]3[/I] apps at once is a really big challenge. What I have found is that the more network services you use, the more updates and test you will need to run and produce. My first app, Anyhub Mobile, had at least 15 version updates within the first year of availability. Adding features and making sure any API changes didn't break something was a challenge. Your last two apps probably depend heavily on web APIs, though I am just taking a wild guess here, but it seems really obvious that they do. Take some time to support them and add new features before slinging out another app. I've made 2 (and soon to be 3) quality apps in ~2 years of developing for iOS. I take time to fix bugs and support them for as long as I can. Other than that, It's nice to see an emerging iOS dev here on facepunch. How are your other apps doing in terms of sales / downloads.[/QUOTE] The slider is slightly styled, I just need to change the thumb image. For the cloud client app, I don't have any features planned, so any further updates from here on out will be bug fixes if any. Reworking the UI might be a possibility but that'll be later I guess. The crowd app only got about 4 downloads (2 from me). From those 2 unique downloads, only one actually signed up to login to use the app. He only used it for about 2 minutes before giving up. Might give up on this app. My first app (a game) that I made a while back got a total of about 8-9 thousand downloads. But the last two apps that hit the app store is pretty low compared to my first app (the cloud client got about 200 downloads). The reason I guess is mainly people check the game category the most compared to the other categories. I'm probably going to submit this speed reading app and work on a game next. After the game, I'll worry about adding more features. As far as web API goes, I used Parse ( [url]www.parse.com[/url] ) for the crowd app. It's pretty sweet and makes web connected apps much easier to develop.
[QUOTE=amcfaggot;33930779]Well, I was going dump the best posters from LMAO Pics v99 after a vote on when I should do it as an fpapi test, possibly listing all of them on New Year's Day or something, something cool for those people who got mentioned, and a little fun for me to carry out the parsing. However, that got derailed into basically a "who gives a shit" feedback response after one Xx~s0 3dg3y~xX kid blanket-rated my posts dumb, regardless of my last post which displayed the top rated posts (nearly the exact same thing) and received multitudes of winner ratings? I'd even go as far as saying it at least got 100+ winner ratings, to put it in perspective, though I honestly can't remember, nor is it in my immediate post history. Okay then, Facepunch. Well, that's the Internet I guess. I suppose I can still use the fpapi for dumping actual highlights in this thread come new years eve. At least here I can post [i](somewhat)[/i] without fear of being flamed with a "Wow, who gives a shit?" mentality. :/[/QUOTE] Isn't this to be expected from the 12 year old scum that lurk in LMAO pics?
[img]http://dl.dropbox.com/u/45554193/images/segfb.png[/img] Wheee
[QUOTE=swift and shift;33928789][cpp] void foo() { throw 123; } void bar() { void* ptr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); foo(); munmap(ptr, 4096); } [/cpp][/QUOTE] I don't quite get what you're saying. Something throws an exception, and you don't catch it, and this is specifically bad when working with C APIs? [editline]28th December 2011[/editline] [QUOTE=synthiac;33928290]>2011 >not being in fpp steam chat[/QUOTE] Hey bro, Steam doesn't work on Linux.
[IMG]http://dev.flyingpie.nl/steamdroid.png[/IMG] It's a toaster
[QUOTE=Jookia;33931899]I don't quite get what you're saying. Something throws an exception, and you don't catch it, and this is specifically bad when working with C APIs?[/QUOTE] The program might never reach deallocation or whatever is needed to clean up your resources and such. With C++ classes the destructors are called even when exceptions are thrown.
got battlecars talking to the network [img]http://i.imgur.com/U2ghD.png[/img] SFML/STL/whatever was giving me the shits because something like this segfaulted: [cpp] std::string name; packet >> name; [/cpp] But something like this worked: [cpp] std::string name(32, 0); packet >> name; [/cpp] [editline]28th December 2011[/editline] In fact, any initial size for the string appears to work, as long as there's [i]something[/i] that's preallocated. Strange..
[QUOTE=Jookia;33931899]Hey bro, Steam doesn't work on Linux.[/QUOTE] Then start using Windows. I don't see how you could prefer any linux distro over Windows 7 for general usage...
[QUOTE=Dlaor-guy;33932584]Then start using Windows. I don't see how you could prefer any linux distro over Windows 7 for general usage...[/QUOTE] Because XMonad + KDE > Windows 7
[QUOTE=Dlaor-guy;33932584]Then start using Windows. I don't see how you could prefer any linux distro over Windows 7 for general usage...[/QUOTE] Some people have different preferences.
[QUOTE=Dlaor-guy;33932584]Then start using Windows. I don't see how you could prefer any linux distro over Windows 7 for general usage...[/QUOTE] To be honest I used Ubuntu for a little while and apart from the fact that I couldn't play games surfing the web using skype etc was great. I prefer the linux version of skype and everything runs so fast and stable.
[QUOTE=sim642;33932140]The program might never reach deallocation or whatever is needed to clean up your resources and such. With C++ classes the destructors are called even when exceptions are thrown.[/QUOTE] Yes but that has nothing to do with what I said. [editline]28th December 2011[/editline] [QUOTE=Dlaor-guy;33932584]Then start using Windows. I don't see how you could prefer any linux distro over Windows 7 for general usage...[/QUOTE] Well considering Windows prevents me from using a computer properly, I don't use it.
OS war yay.
[QUOTE=Maurice;33932767]OS war yay.[/QUOTE] WAYWO: OS war edition
[QUOTE=NovembrDobby;33908260] [img]http://i.imgur.com/83vlR.gif[/img] [/QUOTE] I'd suggest reworking your "YOU LOST" screen a bit. I think it would work well and look a lot better if, when you died: your input is frozen; the screen flashes momentarily; your player pops in a shower of sparks or other death-effect; then a slightly lengthier pause before every other enemy pops sequentially (not simultaneously). You could then fade the screen to the high-score menu or something like that, but I think as it stands it's horrendously jarring to suddenly have the "you lost" thing bannered across the screen (not to mention how the rest of the UI suddenly disappears). [QUOTE=reevezy67;33932622]I prefer the linux version of skype and everything runs so fast and stable.[/QUOTE] I cannot overstate how much more enjoyable the linux version of skype is to use than the windows version.
[QUOTE=mechanarchy;33932818] I cannot overstate how much more enjoyable the linux version of skype is to use than the windows version.[/QUOTE] Wish I could use it on windows without having to go through much effort.
[QUOTE=Jookia;33932674]Yes but that has nothing to do with what I said.[/QUOTE] You said this: [quote]POSIX's C API is brilliant and doesn't require any C++ wrapping.[/quote] Yet I showed you a piece of code using the POSIX API that [i]does[/i] require C++ wrapping to be safe. [editline]28th December 2011[/editline] [QUOTE=reevezy67;33932622]and everything runs [b]so fast and stable[/b].[/QUOTE] [url]http://funroll-loops.info[/url]
[QUOTE=swift and shift;33932942] [url]http://funroll-loops.info[/url][/QUOTE] Funny but I was using Ubuntu, its all pre packaged you don't have to compile your kernel and packages. I wouldn't mind giving Gentoo a shot just as a learning experience not as a permanent OS.
[QUOTE=swift and shift;33932942]Yet I showed you a piece of code using the POSIX API that [i]does[/i] require C++ wrapping to be safe.[/QUOTE] The exception would kill the program as it's uncaught, so it doesn't matter that it's not unmapped. But the whole problem isn't exclusive to using C APIs. That's exclusive to not using objects. It can happen in procedural C++ code. [cpp]void foo() { throw 1234; } void blah() { int* myints = new int[1024]; foo(); delete[] myints; }[/cpp] I could argue that C has the same problem if foo() calls exit(), or uses setjmp.
[QUOTE=Jookia;33933087]The exception would kill the program as it's uncaught, so it doesn't matter that it's not unmapped.[/quote] sorry i didn't realise i had to flesh out my examples into a full working program [cpp] void foo() { throw 123; } void bar() { void* ptr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); foo(); munmap(ptr, 4096); } int main() { while(1) { try { bar(); } catch(int a) { } } } [/cpp] [quote] But the whole problem isn't exclusive to using C APIs. That's exclusive to not using objects. It can happen in procedural C++ code. [cpp]void foo() { throw 1234; } void blah() { int* myints = new int[1024]; foo(); delete[] myints; }[/cpp][/QUOTE] You try not to code like that in C++, but you can't help it if you're using a C API. That's why you wrap it in an RAII object. My argument was that you don't use a C API straight, not that you can't use one at all (because you can't avoid that)
Dude, there's no reason you can't use a C API straight unless you for some reason decide you don't want to catch exceptions from methods that can throw them. You know, what people usually do but for some reason you in particular avoid to do? [cpp]template <typename funcPtr> bool bindOrigFunc(char const* funcName, funcPtr& ptr) { /* dlsym returns void*, but C++ nor C specify that void* is the same size as a function pointer. */ static_assert(sizeof(void*) == sizeof(funcPtr), "void* isn't the same size as a function pointer!"); union { funcPtr realPtr; void* voidPtr; } symHack; symHack.voidPtr = dlsym(RTLD_NEXT, funcName); if(!symHack.voidPtr) { return false; } else { ptr = symHack.realPtr; return true; } }[/cpp] HOLLY SHIT DID I JUST DO THAT? HARDCORE MAN
[QUOTE=Jookia;33933224][cpp]/* dlsym returns void*, but C++ nor C specify that void* is the same size as a function pointer. */ [/cpp][/QUOTE] if a function pointer isn't the same size as a data pointer, you're fucked anyway so just do this: just do [cpp] ptr = (funcPtr)dlsym(RTLD_NEXT, funcName); [/cpp] [editline]29th December 2011[/editline] or if you feel particularly c-plus-plussy, use a reinterpret_cast
[QUOTE=swift and shift;33933269]if a function pointer isn't the same size as a data pointer, you're fucked anyway so just do this: just do [cpp] void(*fn)() = (void(*)())dlsym(RTLD_NEXT, "exit"); fn(); cout << "doesn't reach here" << endl; [/cpp][/QUOTE] Why would I do that if I can catch the error compile-time?
[QUOTE=Jookia;33933279]Why would I do that if I can catch the error compile-time?[/QUOTE] no i was offering that as a replacement for your union clusterfuck. you can still keep the static assert there if you like i guess
[QUOTE=swift and shift;33933269]if a function pointer isn't the same size as a data pointer, you're fucked anyway so just do this: just do [cpp] ptr = (funcPtr)dlsym(RTLD_NEXT, funcName); [/cpp] [editline]29th December 2011[/editline] or if you feel particularly c-plus-plussy, use a reinterpret_cast[/QUOTE] I catch your edit and raise you that it's impossible to convert between void* and a function pointer as per the C++ standard. Not even casting fixes it. [editline]29th December 2011[/editline] [QUOTE=swift and shift;33933294]no i was offering that as a replacement for your union clusterfuck. you can still keep the static assert there if you like i guess[/QUOTE] Hey man, it's the only way to do it.
[QUOTE=Jookia;33933300]I catch your edit and raise you that it's impossible to convert between void* and a function pointer as per the C++ standard. Not even casting fixes it.[/QUOTE] I'm fully aware of that, but who cares? Any compiler will let you do it
[QUOTE=swift and shift;33933309]I'm fully aware of that, but who cares? Any compiler will let you do it[/QUOTE] Uhh, no?
[QUOTE=Jookia;33933344]Uhh, no?[/QUOTE] using a union to convert between the two is just as shady as using a straight cast, i don't know why you have this tendency to make things more complicated than they need to be.
[QUOTE=swift and shift;33933368]using a union to convert between the two is just as shady as using a straight cast, i don't know why you have this tendency to make things more complicated than they need to be.[/QUOTE] "ISO C++ forbids casting between pointer-to-function and pointer-to-object" I have all my compiler warnings turned on and let them all error. A union, or memcpy, is the only legal way in C++ to do what I want.
Sorry, you need to Log In to post a reply to this thread.