I have read C vs C++ stuffs and why C is preferred over C++ but what will be the impact of writing C code compiled with a C++ compiler and using in embedded programs, There might be some difference in standard definitions like null pointer etc.
To make it clearer, if I write a embedded.cpp with just c codes and compile with a c++ compiler, will the resulting code be as efficient as the embedded.c code. My guess is C compilers has been highly optimized and produce optimized code. Is that all the reason ?
Any comparison only makes sense when you are looking at particular compilers. Some leading compilers use the exact same back end for both C++ and C, and library choice (that impacts disk footprint, memory footprint, startup time and almost everything else) is determined quite freely and in a much more granular way than just C vs. C++, supposing you really care.
So in that case the answer would be, no, the file extension does not matter. But calling a C program C is very good to make your decision to limit the product to C to be understood within your team.
Note that a lot of the argument against C++ in embedded development comes from an era a decade or more ago when C++ compilers struggled to implement the language correctly, and sometimes at the expense of predictable performance or runtime size. All today’s practical language wars for embedded devepment that are fought close to me tend to be between C++ and C# and C is rarely even remembered.