avr-gcc: suppress warning "'__progmem__' attribute ignored" - avr-gcc

does anybody know how this warning can be suppressed?
there is no way for me to avoid them (they stem from a framework i use).
Thanks!

From the gcc(1) man page:
-Wno-attributes
Do not warn if an unexpected "__attribute__" is used, such as unrecognized attributes, function attributes applied to variables, etc. This will not stop errors for incorrect use of supported attributes.

just add static to your declaration
PROGMEM static char my_byte[100] = {0x00,0x01,0x02,0x03 ...... }
then retrieve it as
char any_byte;
int index;
any_byte = pgm_read_byte(&(my_byte[index])) ;

Related

GCC: How to customising warning and errors generated from compilation

My Usecase:
I have two c language files: ApplicationCode.c and UserCode.c . Application code is something generated by my app and UserCode is available to my application user where he can write his own code.
ApplicationCode.c internally uses UserCode.c and calls out its methods/function.
One thing you can assume here that ApplicationCode.c will never have any errors but could have warnings generated by gcc compiler. And UserCode.c can have both errors and warnings.
So, While compiling code I wanted to show user his code's errors as first priority. If needed to show warning also then show warning generated by his code only not from ApplicationCode.c (As i don't want to expose my ApplicationCode.c's code).
One more constraint is here that I wanted to show return-type warning as error here and for this I am using -Werror=return-type argument.
So, I am thinking of following three approaches to do this:
If I could able to disable all the warnings and enable only -Wreturn-type
Raised a saparate question for this here
If I could able to instruct gcc (or redirect) only error messages to stderr and rest on stdout.
Raised a saparate question for this also here
If I could able to disable all the warnings (which are enabled by default) from ApplicationCode.c file and enable all with -Werror=return-type for UserCode.c
I tried searching everywhere but did not get any solution for all the above 3. Let me know how could I achieve above problems or if there any other better way to do solve my use case ?
Update 1:
Here is my both the code file look like
ApplicationCode.c
#include <stdio.h>
// some headers
// some application specific code
int testUserFunction(); // user function declaration
int main(int argc, char *a[]) {
int result = testUserFunction(); // calling user function
// some logic to use and evaluate result
}
UserCode.c
#include<stdio.h>
int testUserFunction(int input1)
{
// user will write his code below this
// user code
}
Base command to compile code:
gcc -o code.out ApplicationCode.c UserCode.c
or if there any other better way to do solve my use case ?
If you don't want to "expose ApplicationCode.c", then why are you showing its compilation output in the first place? Solution: Compile it in somewhere secret and let the user link their UserCode.c with it.

Visual Studio 2017: Ruleset won't execute

I want to define a custom set of rules to be checked at compile time. But it seems not to work.
Example:
I choose one rule directly and I'll get the expected warning.
But when I instead create a custom ruleset containing the exact same rule then I won't get the expected warning.
What could be wrong?
Edit:
void f(std::string& i) {
std::string s = i;
cout << s;
}
int main()
{
std::string s ("abc");
f(s);
}
This gives me the expected warning Warnung C26460 The reference argument 'i' for function 'f' can be marked as const (con.3). in the first case.
Even if I create a custom ruleset including all available rules, I won't get any warnings.
Here you see me selecting the custom ruleset:
Edit: The ruleset action must change one time to enable it.
When I create a new ruleset containing only the const-checks then I will get a .ruleset that does not work and look like this:
In the ruleset editor it looks like this:
When I then change its action from Warning to Error:
Then the .ruleset gets additional lines for each test case:
When I change the action back to warning it looks like this:
Now it is working as expected.
I've been able to reproduce your error with Visual Studio 2017. I don't know exactly what I changed (or if I changed anything at all), but I am able to see the code analysis warning you expect with a custom rule set.
Things I would try:
Double check the Error List window is visible and not hiding somewhere.
Open the rule set file, change the Action to Error and then back to Warning and save it. I wouldn't expect this to be the problem but it's one of the things I did and after which I started seeing the Error List window.

'v8::Value::ToNumber': was declared deprecated

I'm trying to access a known object and get one of its properties as a Number
Unfortunately, the following code...
Isolate *isolate = args.GetIsolate();
Local<Object> opts = args[0]->ToObject();
Local<Number> mode = opts->Get(String::NewFromUtf8(isolate, "mode"))->ToNumber();
is giving the following warning:
warning C4996: 'v8::Value::ToNumber': was declared deprecated
....node-gyp\8.5.0\include\node\v8.h(9578): note: see declaration of 'v8::Value::ToNumber'
In the v8.h I noticed the comment on ToNumber: "Use maybe version". I've attempted to convert it to a Maybe but I've not yet been able to get any attempt to compile correctly. What is the correct approach to using Maybe and getting the Number object?
Looks like the "Use maybe version" comment in the v8.h led me in the wrong direction. The deprecate notice seems to apply to the method-overload that is missing the isolate. If you pass the isolate...
->ToNumber(isolate);
it works without warning.

clang: custom attributes not visible in AST

i implemented a custom attribute in clang as described in the official manual:
http://clang.llvm.org/docs/InternalsManual.html#how-to-add-an-attribute
So i added the following Code to Attr.td:
def MyAttr: InheritableAttr {
let Spellings = [GNU<"my_attr">, CXX11<"me", "my_attr">, GCC<"my_attr">, Declspec<"my_attr">];
let Subjects = SubjectList<[Var, Function, CXXRecord]>;
let Documentation = [MyAttrDocs];
}
and the documentation to AttrDocs.td. After rebuilding clang, it obviously knows the attribute because i don't get an unknown attribute warning when using it. I can even access the new attribute class with libtooling, but the attribute doesn't show up in the AST, even if i add the line let ASTNode = 1 to the attribute definition.
Is there something else i need to consider or what could be the problem?
Unfortunately this was my fault, the missing step is described in the manual in section "Boilerplate": i just had to implement the semantic processing of the attribute in SemaDeclAttr.cpp by adding a new case:
case AttributeList::AT_MyAttr:
handleSimpleAttribute<MyAttrAttr>(S, D, Attr);
break;
So it works fine now.

Error while calling member function

Hi I have just started using C++ today, and I am working on checkboxes. I have tried using CheckBox1->Checked in an if statement or whatever, but it isn't working.
The error is:
Error 2 error C2227: left of '->Checked' must point to class/struct/union/generic type
EDIT: The Code is:
void function ()
{
if (1001->Checked)
{
Sleep(2000);
}
}
Without seeing some of your code, it's very difficult to offer targeted assistance.
However, that error message usually comes about because the item you're de-referencing is not a pointer.
Check to ensure it's of the correct type. It should be something along the lines of:
tCheckBox *CheckBox1;
One possibility is that you've declared it not as a pointer to the checkbox but as a checkbox itself:
tCheckBox CheckBox1;
Note the lack of the asterisk there that would otherwise mark it as a pointer. In that case, you would use CheckBox1.Checked rather than CheckBox1->Checked, if it's allowed by the framework (this isn't standard C++ since that beast has no concept of GUI libraries).
If that doesn't help, please post the code so we can offer better suggestions.
Update:
if (1001->Checked) ?????
1001 is not a pointer - it's not a variable of any description, it's an integer constant.
You need to declare and use a variable of some description. First step is, I think, to read up on the documentation for your framework and/or get some sample code that does compile and work, basing your initial work of that.
Use CButton::GetCheck() to determine the state of the checkbox - like so...
CButton* pButton = (CButton*) GetDlgItem(IDC_CHECKBOX_RESOURCE_ID);
if ( BST_CHECKED == pButton->GetCheck() )
{
// button is checked
}