[cfe-dev] Binary size when using std::function with lambda expression
Shoaib Meenai via cfe-dev
cfe-dev at lists.llvm.org
Fri Jan 8 09:26:12 PST 2021
libcxx-dev at lists.llvm.org<mailto:libcxx-dev at lists.llvm.org> might be a good place to send this as well, since it’s possible it’s a libc++ thing.
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of cfe-dev <cfe-dev at lists.llvm.org>
Reply-To: Cyril Makloufi <Cyril.Makloufi at 4d.com>
Date: Friday, January 8, 2021 at 2:45 AM
To: cfe-dev <cfe-dev at lists.llvm.org>
Subject: [cfe-dev] Binary size when using std::function with lambda expression
Hello,
When using std::function instead of function pointer (see the sample of code) on Mac, we get a huge difference between size of generated binary (80ko when using function pointer and 157ko whit std::function).
I use Xcode to build debug with -O0 -std=gnu++14 and libc++.
It doesn't seem to have the same result on windows or linux.
Is it something normal ?
Here's the code sample :
#include <iostream>
#include <functional>
int main(int argc, const char * argv[]) {
std::function<void()> f = [](){std::cout << "LOG2\n";};
// void (*f)() = [](){std::cout << "LOG3\n";};
f();
return 0;
}
Thanks,
Cyril
[cid:image001.jpg at 01D6E5A0.4DC9D7D0]
Cyril Makloufi
Développeur
Email :
Cyril.Makloufi at 4d.com<mailto:Cyril.Makloufi at 4d.com>
Web :
www.4d.com<http://www.4d.com>
4D SAS
66 route de Sartrouville
Parc Les Erables - Batiment 4
78230 Le Pecq - France
Standard :
+33 1 30 53 92 00
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210108/5b58ed2d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 4990 bytes
Desc: image001.jpg
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210108/5b58ed2d/attachment-0001.jpg>
More information about the cfe-dev
mailing list