Click here to Skip to main content
16,019,140 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Why non-template function does not compile where as template function compiles? Pin
k505410-Oct-19 8:53
mvek505410-Oct-19 8:53 
QuestionAdvice on interdependent asynchronous functions and task queuing? Pin
arnold_w7-Feb-19 23:07
arnold_w7-Feb-19 23:07 
AnswerRe: Advice on interdependent asynchronous functions and task queuing? Pin
arnold_w7-Feb-19 23:34
arnold_w7-Feb-19 23:34 
QuestionRecommended way to deal with queues and pointers to buffers Pin
arnold_w3-Feb-19 9:09
arnold_w3-Feb-19 9:09 
AnswerRe: Recommended way to deal with queues and pointers to buffers Pin
Richard MacCutchan3-Feb-19 22:19
mveRichard MacCutchan3-Feb-19 22:19 
GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
arnold_w3-Feb-19 23:40
arnold_w3-Feb-19 23:40 
GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
Richard MacCutchan3-Feb-19 23:48
mveRichard MacCutchan3-Feb-19 23:48 
GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
arnold_w4-Feb-19 3:15
arnold_w4-Feb-19 3:15 
I don't think I can guarantee that the static non-queued buffers can be put in the end of the structs because most of the time the structs will be created on the stack. Therefore, I think I need pointers to the buffers.

I also have a CAN-bus interface and typically the receive packet task would take a struct that looks like this:
C++
struct packet_s {
    uint32_t  extID;
    uint8_t   DLC;    // Data Length Count (=size of packet in bytes)
    uint8_t*  data;
};
In my application these packets will always be queued (they never use static buffers) and as soon as they are queued the data pointer becomes worthless. The best thing I can think of is the following (a slight variation of Richard MacCutchan's suggestion):
C++
#define PLEASE_SEE_DLC_FOR_PACKET_SIZE     (1)

struct packet_s {
    uint32_t  extID;
    uint8_t   DLC;    // Data Length Count (=size of packet in bytes)
    uint8_t   data[PLEASE_SEE_DLC_FOR_PACKET_SIZE];
};


modified 4-Feb-19 9:27am.

GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
Richard MacCutchan4-Feb-19 3:46
mveRichard MacCutchan4-Feb-19 3:46 
GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
arnold_w4-Feb-19 3:55
arnold_w4-Feb-19 3:55 
GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
Richard MacCutchan4-Feb-19 4:04
mveRichard MacCutchan4-Feb-19 4:04 
GeneralRe: Recommended way to deal with queues and pointers to buffers Pin
Business2sell18-Feb-19 18:08
professionalBusiness2sell18-Feb-19 18:08 
QuestionCan a union in standard C "skip" members? Pin
arnold_w31-Jan-19 22:46
arnold_w31-Jan-19 22:46 
AnswerRe: Can a union in standard C "skip" members? Pin
Richard MacCutchan31-Jan-19 23:18
mveRichard MacCutchan31-Jan-19 23:18 
GeneralRe: Can a union in standard C "skip" members? Pin
arnold_w31-Jan-19 23:47
arnold_w31-Jan-19 23:47 
GeneralRe: Can a union in standard C "skip" members? Pin
Richard MacCutchan31-Jan-19 23:52
mveRichard MacCutchan31-Jan-19 23:52 
GeneralRe: Can a union in standard C "skip" members? Pin
arnold_w1-Feb-19 0:13
arnold_w1-Feb-19 0:13 
GeneralRe: Can a union in standard C "skip" members? Pin
Richard MacCutchan1-Feb-19 1:42
mveRichard MacCutchan1-Feb-19 1:42 
GeneralRe: Can a union in standard C "skip" members? Pin
arnold_w1-Feb-19 2:08
arnold_w1-Feb-19 2:08 
GeneralRe: Can a union in standard C "skip" members? Pin
Richard MacCutchan1-Feb-19 2:57
mveRichard MacCutchan1-Feb-19 2:57 
GeneralMessage Closed Pin
16-Apr-20 20:04
xiaofeifei6616-Apr-20 20:04 
AnswerRe: Can a union in standard C "skip" members? Pin
0x01AA5-Jan-22 4:30
mve0x01AA5-Jan-22 4:30 
QuestionWhich type of Regex best to learn for programming with C? Pin
HS_C_Student17-Dec-18 3:43
HS_C_Student17-Dec-18 3:43 
AnswerRe: Which type of Regex best to learn for programming with C? Pin
Richard MacCutchan17-Dec-18 3:53
mveRichard MacCutchan17-Dec-18 3:53 
GeneralRe: Which type of Regex best to learn for programming with C? Pin
HS_C_Student17-Dec-18 5:57
HS_C_Student17-Dec-18 5:57 

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.