Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Josh Gray2

@Josh Gray2
About
Posts
12
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How did you overcome this obstacle ?
    J Josh Gray2

    Knowing more tools and more tech doesn't necessarily relate to making your employer significantly more profit, you might produce less bugs and be slightly more efficient than someone with less experience but it doesn't scale well, they can easily just hire 5 grads instead of giving you 5 times your current salary. Working in financial markets is one place where your coding efforts can have significant impact on a company's bottom line and where the rewards can scale accordingly. Honestly, if you're not a 'wiz' and adding multiple times your peers to the bottom line why would you expect to be further rewarded for experience or years of service to the company or industry? It is fine to plateau.

    The Lounge tools question

  • WML and Coal Chute
    J Josh Gray2

    I've been working at the same company for 16 years, occasionally I find some real nuggets of 2005 Josh code

    The Lounge html csharp announcement

  • I just got beaten up by a 5 ft 100 lb girl
    J Josh Gray2

    Oh man, I'm living in The Netherlands at the moment and had a similar experience at an emergency dentist on new years day. Similarly sized dentist and I had similar concerns, especially when she said "do you want me to try the anesthetic, it probably wont work well due to all the infection". We got there in the end and she told me to take some paracetamol, if I needed it later. I went home and self-medicated

    The Lounge

  • Nuts and bolts - Programming contest
    J Josh Gray2

    I believe that the official scale is neither metric nor imperial. Say you found yourself in a urologists' office with your pants down being told you had a tumor on old lefty and that it has to come out pronto. If this happened to you in Australia about 10 years ago the doctor would likely tell you that the government has a program offering free prosthetics and that he can whack in a replacement at the same time since he'll already have his hand in your scrotum. If you accepted this generous offer he would pull out something which looks a lot like a circle template a draftsman would of used many years ago to determine the appropriate size replacement. In a pretty dark day being told that you're a medium large in bollocks is a real highlight.

    The Lounge html com question

  • Nuts and bolts - Programming contest
    J Josh Gray2

    I believe that the official scale is neither metric nor imperial. Say you found yourself in a urologists' office with your pants down being told you had a tumor on old lefty and that it has to come out pronto. If this happened to you in Australia about 10 years ago the doctor would likely tell you that the government has a program offering free prosthetics and that he can whack in a replacement at the same time since he'll already have his hand in your scrotum. If you accepted this generous offer he would pull out something which looks a lot like a circle template a draftsman would of used many years ago to determine the appropriate size replacement. In a pretty dark day being told that you're a medium large in bollocks is a real highlight.

    The Lounge html com question

  • Just one well placed virtual function saves the day
    J Josh Gray2

    This is a very specific topic but oddly I received an email from a colleague today about a library called simdjson which gives a significant performance improvement over other c++ json libraries. simdjson claim 'Standalone UTF8 Validation' at 13/GB/s

    The Lounge performance json

  • Performance woes. I'm appalled.
    J Josh Gray2

    Are you familiar with the Compiler Explorer[^] ? It's a very useful tool for looking at the assembly generated by gcc and other compilers

    The Lounge json performance visual-studio help tutorial

  • How many cores do you need?
    J Josh Gray2

    I have 96 core boxes at work, they're awesome

    The Lounge asp-net com question

  • What is the longest programming misconception you've held (that you are aware of)?
    J Josh Gray2

    Here's an excellent explanation of two's compliment Twos complement: Negative numbers in binary - YouTube[^]

    The Lounge question c++ com

  • What's the closest thing to anonymous function pointers I can achieve that compiles with GCC?
    J Josh Gray2

    arnold_w wrote:

    Could someone knowledgeable in C++ please help with the syntax for the example I provided? Do I need to put it inside a C++ file or it is possible have sections of a C-file containing C++ code?

    #include typedef std::function readDataResultCallback_t;

    typedef struct __attribute__((__packed__)) {
    stateMachineState_e state;
    uint32_t startAddr;
    uint16_t numRegsToRead;
    readDataResultCallback_t readDataResultCallback;
    } stateMachineStep_s;

    stateMachineStep_s stateMachineSteps[3] = {
    {STATE1, 10, 2, [](uint8_t* readData, uint16_t sizeOfReadData) {
    if (stringCompare(readData, "AB") {
    ... Do stuff here...
    state = STATE_2;
    } else {
    ... Do stuff here...
    state = STATE_3;
    }},
    ...

    C / C++ / MFC csharp c++ data-structures tools

  • Reading Files on network box
    J Josh Gray2

    Do you want to force linux to do the windows thing, or windows to do the linux thing? For the former run samba on the linux box and create shares you can access from windows. This will probably suck, the degree to which it sucks will depend on the file system you are using on the linux side. For the latter you can run an ftp server on the linux side or setup ssh and use scp. These will suck less.

    Linux Programming question csharp asp-net dotnet sysadmin

  • What's the closest thing to anonymous function pointers I can achieve that compiles with GCC?
    J Josh Gray2

    the

    readDataResultCallback

    member of your structure is just a fancy pointer, either 32 or 64 bits long depending on your architecture, so it can only be initialised with the memory address of a function. So you could have something like the following...

    void OnState1(uint8_t* readData, uint16_t sizeOfReadData)
    {
    ...
    }

    stateMachineStep_s stateMachineSteps[3] = {
    {STATE1, 10, 2, &OnState1}
    ...
    }

    which, to be honest, is not significantly more typing. You could also use macros to generate some of the code but that comes with it's own issues. C++11 and greater support lambda expressions which will allow you to initialise your structs with a similar syntax to your example but in that case you would have to swap your function pointer to an std::function<> type. If you don't have c++11 support the boost library offers a similar function pointer but without the nicer lambda syntax.

    C / C++ / MFC csharp c++ data-structures tools
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups