Re: [ROOT] strange pb on cxx6.2

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Tue Jan 29 2002 - 13:10:33 MET


Hi Damir, 

On Tue, 29 Jan 2002 09:31:42 +0100
Damir Buskulic <buskulic@lapp.in2p3.fr> wrote
concerning "Re: [ROOT] strange pb on cxx6.2":
> Thanks very much Christian for this very extensive answer !

You're welcome. 

Ok, some people didn't like my example of 

  `This File has a bloody long name - so I can use more disk space and spend more $!.doc'

* One pointetd out that you _can_ have long file names on Unix.
  Ofcourse you can have long file names in Un*x - that's not the
  point.  The point is that Windoze users make names like the above,
  containing other cahracters than [a-zA-Z0-9_.], more often than Un*x
  users does.  Why? I don't know.  Another point is, that if you want
  to use spaces, ladida in a Un*x filename, then you need to escape
  those glyphs, or quote the entire filename. That's a good idea,
  'cause it forces people to be careful (Un*x making people careful -
  that's a new one :-) 

* One remembered back 2-3 years ago where everybody was laughing at
  the Dos 8.3 filename limitation in Windoze.  Well, I thought about
  this morning, and I occured to me, that the file above would
  probably be named  

    `THIS~F~1.DOC' 

  internally, so we're still down to 8.3 filenames - and the head (?) 
  Borg thought he said goodbye to Mr. Dos - ha! :-)  Yeah, I know -
  too much /.. Anyway, the point wasn't  as much the lenght of the
  filenames, but the odd characters in it.  

> But you can easily imagine I was not going to name one of my files
> "baaaa#pka.h". 

Yeah, I was wondering why you would do that, espacially since `#' is
the comment-begin marker in the shell, and you'd have to escape it. 

> In fact, this was done by ACliC automatically. I suppose  this is a
> problem with the way temporary file names are generated, hence a
> problem with some libc routine like mktemp or some such.  

It seems odd that ACliC (which I never use - see below) should
emit the character `#' in a filename ... hmm.  Hope ROOT team will fix
it.

I guess the ANSI C spec has something to say about the possible
characters that can go into the result of tmpnam (which is what I
believe is used - it should really be something like tmpfile or
mkstemp due to security and reantrant-ness). 


FYI, here's a BASH shell function that does (almost?) the same as
ACliC: 

  function root-module () {
     if test $# -lt 1 ;then 
       echo "I need an argument" 
       return 1
     fi
     switch ($1) 
     *.h|*.hh|*.H) echo "I need the implementation file" ; return 2 ;; 
     *.cxx)        name=`basename $1 .cxx` ; ext=.cxx ;; 
     *.cc)         name=`basename $1 .cc`  ; ext=.cc  ;; 
     *.C)          name=`basename $1 .C`   ; ext=.C   ;; 
     *)            name=$1                 ; ext=.cxx ;;   
     esac
     dir=`dirname $1`
     if test "x$dir" = "x" ; then dir="./" ; else dir="${dir}/" ; fi
     shift
     rootflags="`root-config --cflags --glibs` -Wl,-rpath,`root-config --libdir`"
     cflags="-c -Wall -g `root-config --cflag` $* -o" 
     soflags="-shared -Wl,-soname,${name}.so -Wl,-rpath,`root-config --libdir` $*
     obj=`mktemp /tmp/${name}XXXXXX`.o
     c++ ${dir}${name}${ext} ${cflags} -o ${obj}
     if test $? -gt 0 ; then 
       echo "Compilation of ${dir}${name}${ext} failed"	
       return 3
     fi
     for i in .h .hh .H ; do 
       if test -f ${dir}${name}.${i} ; then 
         dict=`mktemp /tmp/${name}XXXXXX`
         rootcint -f ${dict}.cxx -c $* ${dir}${name}.${i}
         if test $? -gt 0 ; then 
           echo "Dicitionary generation from ${dir}${name}${i} failed"
	   return 4
         fi
         c++ ${dict}.cxx ${cflags} ${dict}.o 
         if test $? -gt 0 ; then 
           echo "Compilation of ${dict}.cxx failed"	
  	   rm -f {dict}.{cxx,h} ${obj}
           return 5
         fi
	 rm -f {dict}.{cxx,h}
         dict="${dict}.o"
         break
       fi 
     done
     c++ ${soflags} ${dir}${name}.so ${dict} ${obj}
     if test $? -gt 0 ; then 
       echo "Linking of ${dir}${name}.so failed"
       rm -f {dict} ${obj}
       return 6
     fi
     rm -f ${obj} ${dict}
   }

Who needs Perl :-) 

Out it in your ~/.profile, and use it like 

  > ls 
  Foo.cxx    Foo.h 
  > root-module Foo -I/usr/local/include/bar -DHAVE_BAR 
  > ls 
  Foo.cxx    Foo.h     Foo.so 

Yours, 

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET