Author Topic: Extensionless header files  (Read 4024 times)

Brandon Hamm

  • Community Member
  • Posts: 30
  • Hero Points: 1
Extensionless header files
« on: February 23, 2007, 07:40:01 am »
Is anyone using Slickedit with a project like OpenSceneGraph or other such product using extensionless header files in multiple directories?  For the uninitiated, OSG's directory structure:

Code: [Select]
\include
  \osg
  \osgFX
  \osgDB
  \osgIntrospection
  \osgTerrain
...and so on.  In the "Extensionless C++ File Path Regular Expression" box, I've added the following:

Code: [Select]
osg|osgDB|osgFX|osgGA|

...and all of the other directories containing the headers, but I've yet to get SE to recognize any of them as C++ header files.  There is far too many for it to be practical to enter each file in by hand.

Does anyone have any suggestions or have any experience dealing with this?

Thanks in advance,
Brandon

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2036
  • Hero Points: 248
Re: Extensionless header files
« Reply #1 on: February 23, 2007, 06:09:37 pm »
It's very unfortunate that C++ ever adopted the use of extensionless header files, but the good news for you is that you are half way towards getting things working.

You have set up the include path regex.  The other thing you have to do is set up the names of the extensionless files.

We have been forced to error on the side of caution when it comes to opening an extensionless file as C++.  So, the file must be in the list of extensionless header files AND in a directory path that matches the extensionless header file include regex.  Why?  We are trying to avoid making the editor open some random binary file thinking it's gonna get C++.  There are two esoteric cases:

   1) An extensionless Unix executable or other binary file under include directories.
       A popular linux distribution did this, forcing us to require more than
       just the directory regex.

   2) A binary file that shares the name of a C++ extensionless header, such as a "map" file.
       We had users complaining that they had a data file with this name and it was being
       opened as C++ in an earlier release of SlickEdit.

You may also want to encourage OpenSceneGraph's creators to reconsider their decision to use extensionless header files.  They clearly are thinking that they are conforming to standards, but the C++ Standard only uses extensionless header files as part of the STL, which is the way it is because it was a forever-to-be-regretted bad hack in order to wrap legacy headers into the std namespace.  AFAIK, nowhere in the standard do they recommend creating extensionless headers instead of using .h or .hpp.

Brandon Hamm

  • Community Member
  • Posts: 30
  • Hero Points: 1
Re: Extensionless header files
« Reply #2 on: February 25, 2007, 09:53:16 pm »
Argh...I was afraid of a response like that.  OK, so I use SlickEdit on a couple of machines (a Windows box and a Linux machine) and would really, really, really prefer not to have to enter each OSG header file name into extensionless header files dialog.  Once I do this on one machine, what file is this stored in so that I might copy it to my other machine and not have to enter them all twice.

Thanks for the help!
Brandon

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Extensionless header files
« Reply #3 on: February 25, 2007, 11:12:43 pm »
The related variables are def_cpp_include_path_re and def_user_langext_files.
You can set them on cmdline with set-var def-cpp-include-path-re or def-user-langext-files

But if you've to deal with a large number of files/dirs you should use the underestimated fileman feature.
1. change to the root include path and use 'fileman' on cmdline or 'Files->File Manager'
2. use a smart way of selecting all the entries you want to deal with (there are quite a lot of possibilities -> see context menu)
3. finally do a 'context menu -> Repeat command' and use (one of) the tiny helpers below.

You should use the '%n' parameter b/c all entries are set w/o path.

Add these to e.g. your vusrmacs.e ( check that there is a #include 'slick.sh' ;) )
Code: [Select]
_command void addextlessdir ( _str dir = '' )
{
   int   idx = find_index("def_cpp_include_path_re",VAR_TYPE);
   _str  val = _get_var(idx);
   strappend( val, '|'dir );
   _set_var ( idx, val );

   // say ( "def_cpp_include_path_re: " val );
}

_command void addextlessfil ( _str fil = '' )
{
   int   idx = find_index("def_user_langext_files",VAR_TYPE);
   _str  val = _get_var(idx);
   strappend( val, ' 'fil );
   _set_var ( idx, val );

   // say ( "def_user_langext_files: " val );
}

Maybe it's better to copy and save the contents of the vars before doing all that (by using set-var mentioned above and copy to clipboard -> to a file).
You could also do all that on one machine and copy the resulting variable contents to the other machine and set the vars there just on cmdline.

Good luck,

HS2

Brandon Hamm

  • Community Member
  • Posts: 30
  • Hero Points: 1
Re: Extensionless header files
« Reply #4 on: February 25, 2007, 11:25:56 pm »
Incredibly helpful...I can't thank you enough!