LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what does #ident does in C program in linux (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-ident-does-in-c-program-in-linux-863688/)

bhismnarayan 02-19-2011 02:12 AM

what does #ident does in C program in linux
 
hello
i want to know what does #ident does in C program in linux.
I m having confusion in this.

tronayne 02-19-2011 08:44 AM

The #ident is used to provide information about a compiled program or function such as its version, date created or edited and the like. A utility, what, would be used; e.g., what func.o, to display that information. The information is filled-in by a source code management system such as SCCS, RCS or CVS.

For example, you would create a source file with this at the beginning:
Code:

#ident  "$Id$"

/*
 *      Copyright (C) 2000-2011 Your Name
 *
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of version 2 of the GNU General
 *      Public License as published by the Free Software Foundation.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *      General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public
 *      License along with this program; if not, write to the Free
 *      Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 *      MA 02111-1307, USA.
*/
/*
 *      Name:          $Source$
 *      Purpose:
 *      Version:        $Revision$
 *      Modified:      $Date$
 *      Author:        Your Name
 *      Date:
 *      $Log$
*/

When a file containing these $token$ strings is placed into, say, CVS, those tokens will be translated into
Code:

#ident  "$Id: histfile.c,v 1.1.1.1 2009/10/07 18:06:40 trona Exp $"

/*
 *      Copyright (C) 2000-2009 Your Name
 *
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of version 2 of the GNU General
 *      Public License as published by the Free Software Foundation.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *      General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public
 *      License along with this program; if not, write to the Free
 *      Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 *      MA 02111-1307, USA.
 *
 *      Name:          $Source: /usr/local/cvsroot/utils/histfile.c,v $
 *      Purpose:        display content of a user's .sh_history file
 *      Version:        $Revision: 1.1.1.1 $
 *      Modified:      $Date: 2009/10/07 18:06:40 $
 *      Author:        Your Name
 *      Date:          24 Jun 2009
 *      $Log: histfile.c,v $
 *      Revision 1.1.1.1  2009/10/07 18:06:40  trona
 *      initial installation Slackware 13.0
 *
*/

Of particular interest is the $Log$ token; in a project where code is edited by many hands, every edit is recorded with a comment described what what done, why it was done and when it was done.

Unfortunately, the what utility is not ported to Linux but can be gotten from The Heirloom Project hosted at Sourceforge if you're interested.

Hope this helps some.


All times are GMT -5. The time now is 09:24 AM.