Author Topic: problem in string.h lib in codevision  (Read 835 times)

0 Members and 1 Guest are viewing this topic.

Offline tariqTopic starter

  • Contributor
  • Posts: 24
  • Country: ir
problem in string.h lib in codevision
« on: July 29, 2021, 07:46:30 pm »
hi
I'm using codevision AVR. in string.h lib when one of the arrays is const an error occurs.

for example i want to put a array of string from one array to another like this :

unsigned char A[11];
const unsigned char B[11]={"HELLOWORLD"};

when i use strncpy like this:

strncpy(A,B,10);

i have this error

Error:, #included from: main.c: function argument #2 of type 'flash unsigned char [11]' is incompatible with required parameter of type 'unsigned char *'

and this is the same for all of string.h lib functions.

in ARM and keil compiler i didn't had this problem but in codevision error occurs.

i know i can use for loop but is there any way to avoid this error?
 

Offline richmit

  • Contributor
  • Posts: 43
  • Country: us
    • https://www.mitchr.me/
Re: problem in string.h lib in codevision
« Reply #1 on: July 29, 2021, 09:02:34 pm »
 

Offline esepecesito

  • Regular Contributor
  • *
  • Posts: 62
  • Country: de
Re: problem in string.h lib in codevision
« Reply #2 on: July 30, 2021, 05:16:37 pm »
When you made the constant, it will be placed in ROM (flash). The library seems not to be able to copy from flash to RAM.
I do not know what you are trying to do, to help with a workaround for it.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21658
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: problem in string.h lib in codevision
« Reply #3 on: July 30, 2021, 05:48:09 pm »
strncpy_P
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf