There's no problem with using an extension cord, however before you go out and buy #12AWG wire, make sure it's the correct size.
You may only need 14 gauge, in which 12 AWG is fine, however if you need #10 AWG the #12 isn't any good.
What is the current rating of your compressor?
Regard, Rod