I am using arm compiler 6 and I have a use case where I need to place a number of variables under one particular section.
For a single variable , it works fine .
Like :
int var __attribute__((mysec))
In my scatter (linker) file, var variable appears correctly in the address pointed by “mysec” section.
Now, I have a usecase where I need to store var, var1 and var2 in the same section - “mysec”.
I also want to avoid using __attribute__((mysec)) for each variable.
I found something related to pragma that could help here , but nothing worked out .
Can you let me know if there is any way possible for this?
Related
In this paragraph it states that useContents "temporarily places the CValue to memory, and then runs the passed lambda with this placed value T as receiver".
A few questions about this:
Since this implies that T is not in memory at this moment, is there a risk that useContents fails because the value no longer available?
What happens if I do this: val foo = bar.useContents { this }. Does this copy T? Is it now in memory permanently? Do I need to clean it up manually somehow?
Why is this even necessary? Can't the compiler take care of these details? I just end up writing a lot of extension functions to hide useContents.
I want to compare c and XML files with Beyond Compare. But I want to detect if there are differences within a Block to the corrosponding on the other file and if there is a difference in a block I dont want Beyond Compare to Show the difference in the block, but handle it like this block is not in the other file. I Need this because in my files are certain Code blocks which are nearly the same but do have different Signalnames in it.
So for example i got a c file that Looks like this:
//1
functioncall(
Singalname1,
Singalname2,
Singalname3,
Singalname4,
Singalname5,
Singalname6);
//2
functioncall(
Singalname31,
Singalname32,
Singalname33,
Singalname34,
Singalname53,
Singalname36);
And a second file which Looks like this:
//1
functioncall(
Singalname1,
Singalname2,
Singalname3,
Singalname4,
Singalname5,
Singalname6);
//2
functioncall(
Singalname371,
Singalname372,
Singalname373,
Singalname374,
Singalname573,
Singalname376);
If I compare those two files with BeyondCompare it determines the difference within the second function call because the signalnames all contain a 7. But i want Beondcompare compare the whol functioncall an if there are differences in the functionCall to Show the functioncall beside empty space so i can add it eaily to the second file.
So not like this:
I want it like this:
I tried to add some comments with a begin comment and an end comment with a incrementing number in it something like this:
//begin1
functioncall(
Singalname1,
Singalname2,
Singalname3,
Singalname4,
Singalname5,
Singalname6);
//end1
And then adding a specific rule in beyond compare. Unfortnatly i did not manage to add this rule to beyond compare.
Furthermore Ithink the Code is not good with this comments in it.
Beyond Compare doesn't provide a method to do this. The best workaround is to use the right click Align With command to shift the function alignment.
Did you try the "Never align differences" checkbox in the Alignment tab of the session settings?
I have a UserForm with a ListBox for the user to select values. Those values are populated in UserForm_Initialize() via a function call to the base module, which returns an array as variant. This works without problems.
If the user selects some values and presses a button, the buttons Click event calls another function in the base module to pass on the user-entered array and compute things. This does not work at all. The value received in the base module is always nonexistent (not even null, but I don't know the correct VBA term, nothing is there at all).
Things I have tried so far:
Passing all arguments ByVal: Did not make a difference
Using global shared variables: This did work, but I don't want to rely on them if all I do is pass a single array to a single function. This also introduces state into the code which has to be managed, especially when reusing the function
Accessing the functions by full qualifiers: Did not make a difference. The functions are found and executed correctly, but the argument variables are empty, therefore the functions fail later on when doing the calculations.
My question is: How can I pass arrays from UserForms to Modules (not vice versa) without relying on global variables and without losing the array content?
This question may be related to this question about passing a String from Form to Module, but the accepted answer does not help in my case (using global variables).
When adding the code as requested in the comments, I stumbled upon that fact that I could print the content of the array, but it would not show anything in the debugger and the size would be 0.
The size issue was because I used Len(array) instead of Application.CountA(array) and I had a leftover On error resume next from earlier still in the code, which meant that no error was raised and size was always set to zero... This was the reason for the strange behaviour.
In a implementation for a real time embedded device, I have a status register variable for each channel (let's blindly assume my embedded device have multiple channels and some work has to be done for each of them).
So here's how the status variable is currently declared:
struct channel_status status[NCHANNELS];
Matter of performance, it is better to use an intermediate global variable that is the copy of the status variable for the selected channel.
Example:
struct channel_status status_shadow;
void some_work() {
for(channel = 0; channel < NCHANNELS; channel++) {
status_shadow = status[channel];
foo(); // Function that use the status_shadow as global
bar(); // "
baz(); // "
status[channel] = status_shadow;
}
Am I not discussing the implementation neither the possibility to use a pointer instead of a variable. My question is related to the name of the intermediate variable.
I chose status_shadow because I think I am doing some kind of shadowing.
Is there a better/more accurate technical name for such intermediate variable ?
Implementation considerations:
The reason why I decided to use this intermediate variable is because it is too resource consuming to pass either the channel pointer i or the status variable to each function foo, bar, baz, ... In terms of performance avoiding stack push/pop can save some precious time in real-time applications.
You are not technically shadowing; you would have to define a variable of the same name to shadow it. Moreover, shadowing is generally frowned upon because careless use could lead to easy confusion.
What you are doing is taking the current item for your cycle, so a suited name could be current_status or cur_status. If you used it as a parameter, so the name would be only contained into the for(), it could have been current or cur_item as well.
Another idea could be temp_channel_status, implying that the value is not to be considered fixed albeit the variable is global.
I would like a name such as work_status or status_copy.
You could use status_local, or status_local_copy.
I need to assign data field (component of another field symbol) to field-symbol in a several places of code. For the sake of reusability I decided to encapsulate this code in procedure, but I cannot understand how to pass field-symbols into this procedure.
LOOP bseg ASSIGNING <bseg>
...
PERFORM assigning USING <bseg>
CHANGING <wrbtr>.
...
ENDLOOP.
FORM assigning USING <bseg> TYPE bseg
CHANGING <wrbtr> TYPE bseg-wrbtr
IF ...
some logic here
ASSIGN <bseg>-wrbtr TO <wrbtr>.
ELSE
ASSIGN <bseg>-skfbt TO <wrbtr>.
ENDIF.
ENDFORM.
This code does not work.
What should I do to change the field symbol reference too?
This is not possible, at least not the way you try to do it. Field symbols cannot be passed as the pointers they really are. If you need something like that, you'll have to use real references.
Not knowing anything about the rest of your code - it looks a bit weird. Why would you want to change data in BSEG fields directly? I can only assume that you're "abusing" fields to transport some custom value throughout the code, and that's usually a bad idea. And if you need to do this, I'd rather do it this way:
LOOP bseg ASSIGNING <bseg>.
IF foo.
l_my_wrbtr = <bseg>-wrbtr.
ELSE.
l_my_wrbtr = <bseg>-skfbt.
ENDIF.
" ... pro'lly thousands of lines I don't even want to see...
IF foo.
<bseg>-wrbtr = l_my_wrbtr.
ELSE.
<bseg>-skfbt = l_my_wrbtr.
ENDIF.
ENDLOOP.