cpp
This commit is contained in:
parent
ffe1bd554b
commit
bb45784ae4
2 changed files with 6 additions and 36 deletions
10
meson.build
10
meson.build
|
|
@ -1,9 +1,11 @@
|
||||||
project('tutorial', 'c')
|
project('tutorial', 'cpp')
|
||||||
|
|
||||||
CC = meson.get_compiler('c')
|
CC = meson.get_compiler('cpp')
|
||||||
|
|
||||||
zlib = dependency('zlib', version : '1.2.11', static: true, required: true)
|
zlib = dependency('zlib', version : '1.2.11', static: true, required: true)
|
||||||
|
|
||||||
files = files('src/main.c')
|
target_name = 'compressor'
|
||||||
|
files = files('src/main.cpp')
|
||||||
|
|
||||||
executable('compressor', files, dependencies: zlib)
|
|
||||||
|
executable(target_name, files, dependencies: [zlib])
|
||||||
32
src/main.c
32
src/main.c
|
|
@ -1,32 +0,0 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
char buffer_in [256] = {"Conan is a MIT-licensed, Open Source package manager for C and C++ development "
|
|
||||||
"for C and C++ development, allowing development teams to easily and efficiently "
|
|
||||||
"manage their packages and dependencies across platforms and build systems."};
|
|
||||||
char buffer_out [256] = {0};
|
|
||||||
|
|
||||||
z_stream defstream;
|
|
||||||
defstream.zalloc = Z_NULL;
|
|
||||||
defstream.zfree = Z_NULL;
|
|
||||||
defstream.opaque = Z_NULL;
|
|
||||||
defstream.avail_in = (uInt) strlen(buffer_in);
|
|
||||||
defstream.next_in = (Bytef *) buffer_in;
|
|
||||||
defstream.avail_out = (uInt) sizeof(buffer_out);
|
|
||||||
defstream.next_out = (Bytef *) buffer_out;
|
|
||||||
|
|
||||||
deflateInit(&defstream, Z_BEST_COMPRESSION);
|
|
||||||
deflate(&defstream, Z_FINISH);
|
|
||||||
deflateEnd(&defstream);
|
|
||||||
|
|
||||||
printf("Uncompressed size is: %lu\n", strlen(buffer_in));
|
|
||||||
printf("Compressed size is: %lu\n", strlen(buffer_out));
|
|
||||||
|
|
||||||
printf("ZLIB VERSION: %s\n", zlibVersion());
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue