Search results

  1. nslay

    serial programming problem

    Try using fflush like this: printf("%s",outputbuffer); fflush(stdout); // Add this in your readOut() function. Not sure if it will solve your problem. But the buffered I/O could be a problem. Or use setbuf to switch stdout to unbuffered I/O in your main() function: setbuf(stdout, NULL);
  2. nslay

    serial programming problem

    Maybe you can demonstrate the issue by using ffmpeg to capture an X11 terminal session. I created a script that you can use to easily capture a specific window and it can be found here. You may have to tweak it to output a video instead of a sequence of images. My post on the script also...
  3. nslay

    serial programming problem

    I don't know your exact problem since I can't compile or test your program. However, if your problems are thread related, you could always use select to deal with both stdin and mainfd serially. This removes your use of threads completely. I've modified your code as follows: int mainfd=0...
  4. nslay

    Problem with rand() on FreeBSD

    I know that Linux rand() uses random() underneath. So that would explain the expected behavior. If FreeBSD uses the traditional rand(), then the lower order bits (such as the last 3 bits or mod 8) will not be very random.
  5. nslay

    Why does catching C++ bad_cast not work?

    No, that's not what I'm saying at all. I'm saying that there are thousands of ports written in C++ and several utilities in the source tree written in C++ that rely on standard language behavior (such as catching exceptions!). It's not a just mere annoyance ... it's a serious problem that...
  6. nslay

    Why does catching C++ bad_cast not work?

    I think the ticket should be classed critical with priority high. It's a fundamental feature of the C++ language that should never have problems.
  7. nslay

    Why does catching C++ bad_cast not work?

    That's certainly strange. I originally thought it was a bug in GCC 4.2, but it affects clang and GCC 4.6 also. Maybe you should file a ticket.
  8. nslay

    Clang -std=c++11 -stdlib=libc++ Should enable C++ 11

    While they two may be identical, the name of the executable determines the behavior. Use clang++.
  9. nslay

    Clang -std=c++11 -stdlib=libc++ Should enable C++ 11

    Try using clang++ instead. I think clang is for C.
  10. nslay

    For the beginner C++ programmer

    Because there are some things that POSIX cannot do. It's not necessarily the Linux developers' fault (though it probably is). But at some point, you run into an OS-specific or device-specific problem where there is no POSIX support and you have no choice but to use OS-specific API. Besides...
  11. nslay

    For the beginner C++ programmer

    The application is for FreeBSD ports. Where would he reuse it? Yes, he could use the POSIX API ... but why? It's for FreeBSD! He has the FreeBSD API at his disposal. Why limit yourself? It's not even a practical consideration. EDIT: Furthermore, but being overly general (like supporting every...
  12. nslay

    For the beginner C++ programmer

    pkgsrc is not ports although it is similar. Ports probably could be made to be portable, but it's not and probably won't be in the foreseeable future. EDIT: portmaster isn't even available from OpenBSD ports (The Original Poster did mention using it). My guess is that OpenBSD ports is very...
  13. nslay

    For the beginner C++ programmer

    But he's writing this for ports ... it's already automatically not portable.
  14. nslay

    For the beginner C++ programmer

    While I also like ftw(3), it doesn't allow you to pass an arbitrary argument pointer. Instead you have to expose your argument as a global variable. This is certainly OK if you don't plan to have several instances traversing directories. To be fair, I understand that fts(3) is not necessarily...
  15. nslay

    For the beginner C++ programmer

    fts(3) shouldn't be any slower than using dirent. Use FTS_NOSTAT if you don't need to query permissions, user and group ids ... this should make it much faster. To store the vector of strings, just vDirectories.push_back(pFtsEntry->fts_path) instead of puts(pFtsEntry->fts_path) and there you...
  16. nslay

    For the beginner C++ programmer

    Nothing. But since he's writing this for FreeBSD, he has ftw(3) and fts(3) at his disposal.
  17. nslay

    For the beginner C++ programmer

    I think fts(3) is the easiest way to do this. You can look at find(1)'s source code as it uses fts(3). EDIT: Example: Visit all directories in /usr/ports recursively. FTS *pFtsCtx; FTSENT *pFtsEntry; char * const pathv[2] = { "/usr/ports", NULL }; pFtsCtx = fts_open(pathv, FTS_NOSTAT...
  18. nslay

    Why do you use FreeBSD?

    Doug Barton left!? When did that happen? That's a terrible loss!!! Is there a mailing list post detailing his departure? I'm quite saddened by this ...
  19. nslay

    Learning C programming, C99 or not

    C99 has restrict pointers and inline functions (which are very confusing compared to C++ inline) ... these are the biggest reasons you should learn C99. C99 struct initialization is nice as is the variadic macro support. It also has some other niceties that were standard in POSIX prior to C99...
  20. nslay

    Unix in a keyboard-less age

    Historically, we've been advancing in technology ... and it's still pretty reliable (sometimes even more-so than older and simpler technology). Granted, more parts does make for more points of failure. The real kicker is that machine learning methods build themselves (small chance for human...
Back
Top