[cfe-dev] [RFC] New file extension for compiling C++ for OpenCL sources

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 17 14:12:06 PST 2021


On 17/02/2021 16:36, Arthur O'Dwyer via cfe-dev wrote:
> FWIW, as a complete outsider, as a complete non-user of OpenCL (but a 
> heavy user of C++), I don't see why a new filename extension is a good 
> thing. 


I'm also an opencl outsider.

However, if opencl files are to be detected by a buildsystem like (but 
not limited to) cmake, then a file extension is a good thing. Consider 
this cmake code:

cmake_minimum_required(VERSION 3.10)

project(testproj C CXX OBJCXX OBJC)

add_library(test
     test.cpp
     test.c
     test.m
     test.mm
)


CMake detects the source-language of each source file and uses the 
appropriate driver and language compile option for each one.

With a file extension for opencl, CMake could use the appropriate 
driver/option for that language too. Without a distinct file extension 
for it, the user would have to tell cmake what the language is, which is 
inconvenient for the user.

Thanks,

Stephen.




More information about the cfe-dev mailing list