|
Add this line somewhere before the first reference to FILE_FLAGS :
typedef int FILE_FLAGS;
|
|
|
|
|
I encounter another error if I made these modifications:
data->com = na->flags & ATTR_IS_COMPRESSED;
(where data->com is int )
because now ATTR_IS_COMPRESSED is #define , not part of enum FILE_FLAGS ...
modified 8-Oct-19 5:37am.
|
|
|
|
|
What is data->com ?
_Flaviu wrote: because now ATTR_IS_COMPRESSED is #define , not part of enum FILE_FLAGS That is not the reason. I can only assume that you have done a partial change and some parts of your code are still incorrect. If you still have the FILE_FLAGS enum then it is going to cause problems.
It would probably help if you showed all the code portions that are connected. It is difficult to be certain of the answers when looking at only a single line of code.
|
|
|
|
|
I still cannot see enough information. Please provide what I previously requested and reply to this message. Please do not email me personally.
|
|
|
|
|
I only said that I updated the previous post. Ok, I will come with new informations.
|
|
|
|
|
The fact is like that: I have an error:
error C2059: syntax error : '='
the error is reported here:
data->com = na->flags & ATTR_IS_COMPRESSED;
where:
data is a struct:
struct data
{
.....
int com;
...
};
and na is
RECORD* na;
and RECORD is:
typedef struct {
....
....
int flags;
.....
}RECORD;
and
ATTR_IS_COMPRESSED is from here (from my modifications):
typedef int ATTR_FLAGS;
#define ATTR_IS_COMPRESSED = 0x0001
#define ATTR_COMPRESSION_MASK = 0x00ff
|
|
|
|
|
Not sure why you posted all that back to front ...
However there are a couple of simple mistakes:
#define statements do not require an = sign. They should be
#define ATTR_IS_COMPRESSED 0x0001
#define ATTR_COMPRESSION_MASK 0x00ff
The name data refers to a struct definition, not a variable. You need something like:
typedef struct
{
.....
int com;
...
} DATA;
DATA* data;
I am assuming that you actually assign the memory required for both structures at some point further on.
|
|
|
|
|
That was the problem, on #define : I assigned with '='. My bad !
|
|
|
|
|
This warning from post title is more an information than a warning: unary minus operator applied to unsigned type, result still unsigned
but is signaled here:
static unsigned char buffer[512];
static long long var = -sizeof(buffer) - 1;
Still, how can I rid of this warning ?
|
|
|
|
|
You can cast the result of the sizeof call to a long long prior to apply it the unary minus operator:
static long long var = -((long long)sizeof(buffer)) - 1;
It makes sense when you think of what should the result be when you try to negate a value of a type which does not accept negative values.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Thanks. That warning has disappeared.
modified 4-Oct-19 10:19am.
|
|
|
|
|
I have created a ComboBox with drop down using the wizard and added three data(First,Second and Third) through properties. So what I didn't understand is that in the MyDlg::OnInitDialog() when I commented the base OnInitDialog() the data in the drop down doesn't show up, why?. I know that the base OnInitDialog() call UpdateData(), but even if I keep UpdateData(FALSE) below it, it didn't work.
Could you please help me clear my doubt. Thanks in advance.
BOOL MyDlg::OnInitDialog() {
CDialogEx::OnInitDialog();
UpdateData(FALSE);
return TRUE;
}
|
|
|
|
|
You nee to call the base version to complete proper initialisation. Always refer to the documentation for the MFC classes to ensure you are following the rules.
|
|
|
|
|
My product has registers that are accessed via addresses:
#define MY_REG_0 ((uint32_t)0)
#define MY_REG_1 ((uint32_t)1)
#define MY_REG_2 ((uint32_t)2) Some of these registers (but not all!) need to be shared with another product and I have put them in a common git submodule:
#define MY_PRODUCT_MY_REG_1 ((uint32_t)1) Is this the recommended way to do it? I would like to have a macro
CHECK_ADDR_MACRO(MY_REG_1, MY_PRODUCT_MY_REG_1); that generates static_assert compile time error if:
a) MY_REG_1 and MY_PRODUCT_MY_REG_1 are not equal.
b) Neither MY_REG_1 or MY_PRODUCT_MY_REG_1 are defined (the register was removed, but someone forgot to remove the check.
Can someone please recommend a way to implement the macro CHECK_ADDR_MACRO?
|
|
|
|
|
If you have common functionality in two products, what's wrong with abstracting the common functionality into a shared module (or library)? You then have only one definition to worry about, and don't need this macro at all. The bonus is that the code need be maintained once only.
If the products have different functionality but happen to share the same register numbers, they are two different products.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
It's not common functionality, they are products that can be connected/disconnected on the fly and they have a bus in between them (when connected). The register set I want to expose to the other product is a subset of all the registers, that are only available to an administrator PC-application via a USB-cable.
In the shared h-file I also have some structs and enums that are needed to understand what the bytes in the different registers mean.
|
|
|
|
|
It doesn't change what he said generally you want to abstract the interface to functionality not physicality ... you are connecting things.
You are doing "things" when you have to access the registers, you don't just randomly decide to access the registers.
At the moment you are worrying so much about the physical you aren't even thinking about the functionality.
If you consider something like ReadFile or WriteFile they are functions, yet they can whack all sorts of registers from COM port, USB drives, SATA drives. You don't have to provide registers to those functions it works it out from the name and it is all nicely hidden behind the interface. Even consider ethernet socket programming, lots of registers getting used but not once do you ever deal with them. You deal with functionality connect, listen, send, poll etc.
If you consider Linux and Windows and how complex they are they never expose registers outside the driver and the driver interface is purely a functional api. Granted they have the added problem they may need to share registers between threads/tasks etc but that is just another reason to hide register access below a functional abstraction.
So stop and think what functionality are you doing when you need to whack the registers and can you make a nice functional interface that hides the registers into a common block so they don't ever have to be exposed.
In vino veritas
modified 4-Oct-19 10:46am.
|
|
|
|
|
My product is quite low-level, i.e. I'm setting up impedances, gains, current limiters, bias voltages, differential signal on/off, generating PWM signals, etc. Also, communication protocols are cascaded, for example a PC is transmitting a USB-packet to a microcontroller, who in turn forwards this over an SPI-bus to another microcontroller, who in turn forwards this over a CAN-bus, etc and then an ACK/NACK-packet has to travel the opposite direction. So, to have "local" interfaces between different microcontrollers would make this packet forwarding extremely confusing. Especially the CAN-bus is a bit troublesome because of the limited payload size (8 bytes/packet and no, we can't use the improved version that clocks the data faster) and sometimes I need to send several kBytes of data.
|
|
|
|
|
I have following line of code:
open(pathname, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
which generate 2 errors:
error C2065: 'S_IRUSR' : undeclared identifier
error C2065: 'S_IWUSR' : undeclared identifier
I've read on internet that these IDs are declared inside #include <sys/stat.h>
but inside this file I don't have such IDs. But I replaced them with:
open(pathname, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
(I mean: S_IREAD | S_IWRITE) Just to be sure, it is ok like that ?
|
|
|
|
|
The first thing to do is check the Linux/UNIX documentation to see what those flags represent. You can then figure out which Windows flags to use as replacements.
|
|
|
|
|
_Flaviu wrote: it is ok like that ? As long as S_IREAD has the same value as S_IRUSR and S_IWRITE has the same value as S_IWUSR .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Quote: it is ok like that ? Yes.[^]
|
|
|
|
|
I have a table in Excel (i.e. tab-separated data) that I want to copy-and-paste into a C-file. I would like the table to be readable in the C-file as well, i.e. it should be nicely formatted into aligned columns. If I do a "dumb" replace-tabs-with-spaces then my column alignment gets messed up due to the text in the cells not being equal width. Does anybody know of a tool that can convert my tabs with a variable number of space and preserve the nice column alignment?
modified 3-Oct-19 7:47am.
|
|
|
|
|
And how is look if you let tabs space as it is ? Tab is preffered instead of using spaces ... I mean, instead of using ' ', use '\t'.
|
|
|
|
|
_Flaviu wrote: And how is look if you let tabs space as it is ? Not nice at all, some of the text in my cells is 4 characters long and others are 30 characters long.
_Flaviu wrote: Tab is preffered instead of using spaces ... I mean, instead of using ' ', use '\t'. The Internet is already full of discussions about why you should use tabs instead of spaces, please stay on topic and don't let this thread derail into yet another discussion about it.
|
|
|
|