"Is it frowned upon on do something like..."
"or is it better practice..."
"Or is there no preference?"
The phrasing of your question suggests you may already have a natural preference. Try it out.
Although being open to learning new information regarding syntax and semantics is good, be careful from where, or whom you will accept that information. Often programmers, albeit with good intentions will suggest idiomatic constructs when teaching (or persuading) another to form habits in a manner suitable to a particular point of view. However be careful when accepting ideas, in particular when they are narrowly scoped, and use language with too many absolutes. (always do it this way, never use ... ) Smoothly presented but overly pedantic mandates should be scrutinized before settling on them.
Your question addresses a very specific scenario, but consider other scenarios you are likely to encounter to fully address how/when to create and initialize variables...
- will variable also be used as an argument to the function?
- Is the variable required to have global scope?
- or, is it intended to have local (automatic) scope?
- will variable be used in a threaded environment?
Each of these will factor into how you create, initialize, and perhaps maintain the integrity of your variable, thus will likely cause you to once again consider new information.