Click here to Skip to main content
15,884,629 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: FFMPEG encrypt & decrypt Video offline Pin
Victor Nijegorodov13-Jul-20 21:55
Victor Nijegorodov13-Jul-20 21:55 
GeneralRe: FFMPEG encrypt & decrypt Video offline Pin
DARA ALAVI13-Jul-20 22:09
DARA ALAVI13-Jul-20 22:09 
GeneralRe: FFMPEG encrypt & decrypt Video offline Pin
Victor Nijegorodov13-Jul-20 22:23
Victor Nijegorodov13-Jul-20 22:23 
GeneralRe: FFMPEG encrypt & decrypt Video offline Pin
DARA ALAVI13-Jul-20 22:38
DARA ALAVI13-Jul-20 22:38 
QuestionDoes FreeRTOS have built-in support for queues that can hold variable sized elements? Pin
arnold_w12-Jul-20 10:06
arnold_w12-Jul-20 10:06 
AnswerRe: Does FreeRTOS have built-in support for queues that can hold variable sized elements? Pin
Richard MacCutchan12-Jul-20 21:14
mveRichard MacCutchan12-Jul-20 21:14 
AnswerRe: Does FreeRTOS have built-in support for queues that can hold variable sized elements? Pin
leon de boer21-Jul-20 19:32
leon de boer21-Jul-20 19:32 
QuestionWhat's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
arnold_w10-Jul-20 1:28
arnold_w10-Jul-20 1:28 
I am writing code for an ARM processor and compiling with GCC. I have done some C# programming and there you're allowed to declare delegates inside structures. What's the closest thing I can achieve the same thing in my ARM-project? For example, it would great if I could write a state machine like this:
C++
typedef void (*readDataResultCallback_t)(uint8_t* readData, uint16_t sizeOfReadData);

typedef enum {
    STATE1 = 0,
    STATE2 = 1,
    STATE3 = 2,
} stateMachineState_e;

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

static stateMachineState_e state = STATE1;

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;
                         }}},
    {STATE2,    20, 3, { (uint8_t* readData, uint16_t sizeOfReadData) {
                         if (stringCompare(readData, "ABC") {
                             ... Do stuff here...
                             state = STATE_1;
                         } else {
                             ... Do stuff here...
                             state = STATE_3;
                         }}},
    {STATE3,    30,  4, { (uint8_t* readData, uint16_t sizeOfReadData) {
                          if (stringCompare(readData, "ABCD") {
                              ... Do stuff here...
                               state = STATE_3;
                          } else {
                              ... Do stuff here...
                              state = STATE_2;
                          }}},
};
Do I need to write my own pre-compile code interpreter/generator script that would place the anonymous code in functions outside the stateMachineStep_s array or is there something clever I can do (perhaps with macros or C++)?

modified 10-Jul-20 7:38am.

AnswerRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
Josh Gray210-Jul-20 3:30
Josh Gray210-Jul-20 3:30 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
arnold_w10-Jul-20 11:19
arnold_w10-Jul-20 11:19 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
k505410-Jul-20 11:52
mvek505410-Jul-20 11:52 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
Richard MacCutchan10-Jul-20 22:05
mveRichard MacCutchan10-Jul-20 22:05 
AnswerRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
CPallini12-Jul-20 20:33
mveCPallini12-Jul-20 20:33 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
arnold_w12-Jul-20 23:52
arnold_w12-Jul-20 23:52 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
Richard MacCutchan13-Jul-20 2:00
mveRichard MacCutchan13-Jul-20 2:00 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
arnold_w13-Jul-20 3:53
arnold_w13-Jul-20 3:53 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
Richard MacCutchan13-Jul-20 4:29
mveRichard MacCutchan13-Jul-20 4:29 
GeneralRe: What's the closest thing to anonymous function pointers I can achieve that compiles with GCC? Pin
arnold_w4-Aug-20 5:21
arnold_w4-Aug-20 5:21 
Questionuse argv while debugging Pin
chipp_zanuff4-Jul-20 20:08
chipp_zanuff4-Jul-20 20:08 
AnswerRe: use argv while debugging Pin
Richard MacCutchan4-Jul-20 21:09
mveRichard MacCutchan4-Jul-20 21:09 
GeneralRe: use argv while debugging Pin
chipp_zanuff4-Jul-20 22:15
chipp_zanuff4-Jul-20 22:15 
GeneralRe: use argv while debugging Pin
Richard MacCutchan4-Jul-20 22:19
mveRichard MacCutchan4-Jul-20 22:19 
GeneralRe: use argv while debugging Pin
chipp_zanuff4-Jul-20 23:15
chipp_zanuff4-Jul-20 23:15 
GeneralRe: use argv while debugging Pin
Richard MacCutchan5-Jul-20 0:11
mveRichard MacCutchan5-Jul-20 0:11 
GeneralRe: use argv while debugging Pin
chipp_zanuff5-Jul-20 6:17
chipp_zanuff5-Jul-20 6:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.