Re: Re: [RFClue] Constant declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Felix Oxley <lkml@xxxxxxxxx>
> 
> But is there any point in declaring
> 
> const char *foo = "";
> 
> isn't this equivalent to:
> 
> char *foo;

Actually, I think

 char *foo;

is more nearly equivalent to

 char *foo = NULL;

Assigning foo to the empty string in the declaration guarentees that you can dereference the pointer (by comparing strings, for example) without getting a NULL-pointer exception (though I'm not sure that you necessarily get an exception in the kernel, but the principal is the same).


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux