home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,858 of 33,346   
   Zeljko Vrba to woyt.a   
   Re: access violation on static const   
   10 Feb 13 09:07:11   
   
   From: mordor.nospam@fly.srk.fer.hr   
      
   On 2013-02-10, woyt.a  wrote:   
      
   > can change value of val0 const variable but invokes segmentation fault   
   > for val1.  This is known issue, as val1 is put in the read-only memory   
   > page.   
   >   
   > My question is:   
   > 1. is there any way to change static cont variable value?   
      
   You can use platform-specific API to change permissions on the relevant   
   memory page. (e.g., mprotect)   
      
   > 2. is there any way to prevent compiler to put that variable in   
   > read-only memory?   
      
   Sure, don't declare it as const.   
      
   You should read the compiler's documentation.  gcc has a section attribute   
   which directs the compiler to place it in a particular section.  Maybe it   
   also has an option that instructs it to place all const static variables in   
   writable storage.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca