public enum class Library(public val libName: String) { STDIO("stdio") THREAD("pthread") //this could be extended to include different libraries based on platform MATH("math") STRING("string") } fun Runtime.C.includes(varags includes: Library) { //probably better to fold, but whatever =p var sum: String = "" includes.forEach { lib -> sum += "#ifndef __INCLUDED_${lib.libName.toUpperCase}" sum += "#include <${lib.libName}>" sum += "#endif" } //do whatever you need to do to get sum added to the top of the includes } used like: Runtime.C.includes(Library.STDIO, Library.MATH)