Line data Source code
1 : /*-------------------------------------------------------------------------- 2 : * 3 : * test_cplusplusext.cpp 4 : * Test that PostgreSQL headers compile with a C++ compiler. 5 : * 6 : * This file is compiled with a C++ compiler to verify that PostgreSQL 7 : * headers remain compatible with C++ extensions. 8 : * 9 : * Copyright (c) 2025-2026, PostgreSQL Global Development Group 10 : * 11 : * IDENTIFICATION 12 : * src/test/modules/test_cplusplusext/test_cplusplusext.cpp 13 : * 14 : * ------------------------------------------------------------------------- 15 : */ 16 : 17 : extern "C" { 18 : #include "postgres.h" 19 : #include "fmgr.h" 20 : 21 2 : PG_MODULE_MAGIC; 22 : 23 4 : PG_FUNCTION_INFO_V1(test_cplusplus_add); 24 : } 25 : 26 : /* 27 : * Simple function that returns the sum of two integers. This verifies that 28 : * C++ extension modules can be loaded and called correctly at runtime. 29 : */ 30 : extern "C" Datum 31 2 : test_cplusplus_add(PG_FUNCTION_ARGS) 32 : { 33 2 : int32 a = PG_GETARG_INT32(0); 34 2 : int32 b = PG_GETARG_INT32(1); 35 : 36 2 : PG_RETURN_INT32(a + b); 37 : }