You don't need to recompile MAME. Just place that code into a text doc and save with the extension to .lay once you have that file make a folder in the artwork subdirectory of your MAME directory that is named the same as your game. IE: battletoads, at least for MAME .151, is titled btoads.zip so I placed the default.lay file into a "btoads" folder in my artwork directory. There should be an artwork directory in your MAME install by default. Most people use it for custom bezels but I personally like the black letterbox look around my games so I just used this to adjust the margin/gap between the cocktail screens.
So to clarify, place the code above in a default.lay file you create in something like notepad. Then place the default.lay in your artwork folder which should be something like the following if you were doing it for a game like Battle Toads C:\MAME\Artwork\btoads\default.lay
I'm sure there are ways to make this a default but seeing as how I don't use that setup for all games I just applied it to the few I needed. Once you add that file you will be able to select the setup the same way you select cocktail or 4:3 mode. In other words, it will be in the same list when you hit Tab in MAME and then go to your video settings.