is-empty

Empty structs in C

烂漫一生 提交于 2021-01-27 06:50:49
问题 http://c0x.coding-guidelines.com/6.7.2.1.html: 1401 If the struct-declaration-list contains no named members, the behavior is undefined. Does this mean that the following is illegal? struct C { }; Or what does it mean? I used a Convention=>C Ada pointer to an empty struct (in fact empty Ada record) to serve instead void* in my bindings of a C library (because there is no void* in Ada). I wonder if this is incorrect. What do I misunderstand? See also "Do not pass or return structs with no

Empty structs in C

巧了我就是萌 提交于 2021-01-27 06:50:10
问题 http://c0x.coding-guidelines.com/6.7.2.1.html: 1401 If the struct-declaration-list contains no named members, the behavior is undefined. Does this mean that the following is illegal? struct C { }; Or what does it mean? I used a Convention=>C Ada pointer to an empty struct (in fact empty Ada record) to serve instead void* in my bindings of a C library (because there is no void* in Ada). I wonder if this is incorrect. What do I misunderstand? See also "Do not pass or return structs with no

Create an empty 2d array

醉酒当歌 提交于 2020-12-05 07:56:41
问题 I don't like uninitialized VBA arrays, since it's necessary to check if array is initialized, each time prior using UBound() or For Each to avoid an exception, and there is no native VBA function to check it. That is why I initialize arrays, at least doing them empty with a = Array() . This eliminates the need for extra check in most of cases, so there are no problems with 1d arrays. For the same reason I tried to create an empty 2d array. It's not possible simply do ReDim a(0 To -1, 0 To 0)

How to check if object is empty in javascript for all levels in object

本小妞迷上赌 提交于 2020-11-28 07:56:05
问题 I wanted to find out if my object is empty or not for all its nested objects and key-value pairs. for e.g., const x = { a:"", b:[], c:{ x:[] }, d:{ x:{ y:{ z:"" } } } }; this should be an empty object and if any of this contains single value then it should be non empty. 回答1: Here is the way to do what using recursion const x = { a:"", b:[], c:{ x:[] }, d:{ x:{ y:{ z:'' } } } }; function checkEmpty(obj){ for(let key in obj){ //if the value is 'object' if(obj[key] instanceof Object === true){